Convert cycles per degree to sigma in imgaussfilt

8 visualizzazioni (ultimi 30 giorni)
Ling C
Ling C il 11 Giu 2024
Modificato: Ling C il 12 Giu 2024
Hello,
I am trying to filter my images to a certain cycles per degree (cpd). I have obtained the visual angle of the image, and I would like to low-pass filter my images to under 1 cpd using a Gaussian filter. However, I couldn't figure out what sigma I should use in the imgaussfilt function. Is there a direct formula for the conversion?
I was looking at a similar question here, where we first calculate the visual angle, but it does not mention how it relates to the second formula to obtain sigma. Additionally, there is a constant k in the formula, but I am not sure how to determine what is an appropriate k to use. I would appreciate any help. Thank you!

Risposte (1)

Nipun
Nipun il 12 Giu 2024
Modificato: Nipun il 12 Giu 2024
Hi Ling,
I understand that you want to apply a low-pass Gaussian filter to your image at under 1 cycle per degree (cpd). Here's how to determine the appropriate sigma for the imgaussfilt function in MATLAB:
1. Calculate the desired cutoff frequency in pixels:
  • Convert the cutoff frequency from cpd to pixels using the visual angle.
  • For a visual angle of "theta" degrees and image resolution of "R" pixels, the frequency in pixels per degree is "R / theta".
2. Convert to standard deviation:
  • Use the relationship between the standard deviation (sigma) and the cutoff frequency. The standard deviation in pixels is approximately given by: "sigma = R / (theta * 2 * pi * 1.5)"
Here's an example MATLAB code for your reference:
% Given parameters
visual_angle = 30; % example value in degrees
image_resolution = 1080; % example value in pixels
% Convert 1 cpd to pixels
cpd = 1;
frequency_pixels = (image_resolution / visual_angle) * cpd;
% Calculate sigma
sigma = image_resolution / (visual_angle * 2 * pi * 1.5);
% Apply Gaussian filter
filtered_image = imgaussfilt(input_image, sigma);
% Display filtered image
imshow(filtered_image);
title('Low-pass Filtered Image');
For more details on Gaussian filtering, refer to the following MathWorks documentation:
Hope this helps.
Regards,
Nipun
  1 Commento
Ling C
Ling C il 12 Giu 2024
Modificato: Ling C il 12 Giu 2024
Hi Nipun,
Thank you for your reply. May I ask how was this formula sigma = R / (theta * 2 * pi * 1.5) obtained? Also, I believe the sigma calculation should include cpd.
Ling

Accedi per commentare.

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by