cycles/pixel to cycels/degree

15 views (last 30 days)
Rachel
Rachel on 19 Jun 2012
Hi everyone,
I'm a new Matlab user looking for code to change my images from cycles/pixels to cycles/degree. Any suggestions?
Thanks! Rachel

Answers (1)

Dr. Seis
Dr. Seis on 19 Jun 2012
See this link:
About half way down:
F = fft2(image);
nx = size(F, 2);
ny = size(F, 1);
cxrange = [0:nx/2, -nx/2+1:-1]; % cycles across the image
cyrange = [0:ny/2, -ny/2+1:-1];
[cx, cy] = meshgrid(cxrange, cyrange);
fxrange = cxrange * 2*pi/nx; % radians per pixel
fyrange = cyrange * 2*pi/ny;
[fx, fy] = meshgrid(fxrange, fyrange);
Is this what you want instead?
  1 Comment
Rachel
Rachel on 19 Jun 2012
Thanks for responding Elige. Part of the problem is that I'm such a newbie I'm not sure what code I need. I'm a vision researcher (with no programming background) interested in analyzing the spatial frequency content of a .pbm image depicting a man-made scene (i.e., a cityscape). I'm using the following Matlab FFT code:
I = imread('image.pbm');
F = fft2(double(I));
A = fftshift(F);
L = log2(S);
A = abs(L);
imagesc(A)
Since my last posting I've figured out that when I histogram my 2D power specturm of A I'm actually getting the average spatial frequency of the image in cycles/degree. From here all I want to do is add on code that will then take this information and convert it to cycles/degree. So for example, if my city image is on average 10 cycles/pixels, how do I figure out what this is in cycles/degree?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!