I started (a small project) to calculate the image power spectrum in the frequency domain.
So, I still have the following:
%// close all; clear all; %// not generally appreciated
img = imread('ajw_pic.jpg','jpg'); % it is a color image
img = rgb2gray(img); %// change to gray
psd = 10*log10(abs(fftshift(fft2(img))).^2 );
figure(2); clf
mesh(psd)
So far it looks good; I get a net plot that resembles the spectra that I see in various scientific articles.
However, what I'm looking for is a graph of the graph of these power spectra versus frequency, and I'm not quite sure how to get this frequency vector. I could do for example:
N=400; %// the image is 400 x 400
f=-N/2:N/2-1; %// possible frequencies?
but I’m not sure that this is absolutely correct, as it leads to negative frequencies.
I would really appreciate it if someone could point me in the right direction to build a log frequency depending on the power spectrum.
source
share