Computing Mean Spatial Frequency of Image?

I'm trying to compute the average spatial frequency of some images. The code I'm using is:
files = dir('*.jpg');
images_emo = cell(numel(files),1);
i=1;
for file = files'
images_emo{i} = imread(file.name);
im=double(rgb2gray(images_emo{i}));
imgFFT = fft2(im);
emo_sf_av(i) = mean(mean(abs(imgFFT)));
i=i+1;
end
Is this accurately computing the mean spatial frequency? And in what units?

回答 (1 件)

Image Analyst
Image Analyst 2017 年 2 月 22 日

0 投票

No, it does not. That computes the mean power of all the spatial frequencies. It would be like if you had a set of normally distributed random numbers and took the histogram and then took the mean of the counts. You'd have the mean bin height - the mean of the counts (the y axis) - you would not have the mean value of the x (i.e. frequency) axis , which is what I think you want. To get the mean y you do sum(y*x)/sum(x) and to get the mean x you do sum(y*x)/sum(y). Those are just standard formulas.

6 件のコメント

Gina D'Andrea-Penna
Gina D'Andrea-Penna 2017 年 2 月 22 日
What would the x values (frequencies) be in this case?
Image Analyst
Image Analyst 2017 年 2 月 23 日
The y or x direction spatial frequencies would be the row or column index of your fft spectrum, multiplied by the spatial calibration factor to convert pixels into line pairs per meter or mm or whatever. Of course that depends on your field of view if you want to use actual real-world units.
Ajay Shankar
Ajay Shankar 2018 年 8 月 31 日
Can I have code for finding y or x direction spatial frequencies in terms of pixels itself
Image Analyst
Image Analyst 2018 年 8 月 31 日
編集済み: Image Analyst 2018 年 8 月 31 日
Just call fft() on individual rows or columns of your array
fftRow = fft(grayImage(row, :))
Ajay Shankar
Ajay Shankar 2018 年 9 月 3 日
Thanks by extracting row got spectrum as attached like in my improfile however fftRow is not giving me periodicity or spatial frequency see its plot. What to do . I used code grayImage= imread('D:\010020.jpg'); imshow(grayImage); grayLevel = grayImage(10, :); plot(grayLevel); fftRow = fft(grayLevel); plot(fftRow);
Image Analyst
Image Analyst 2018 年 9 月 3 日
Ajay, attach a screen shot as a PNG file, not a fig file - they're easy to see right here in the browser.
Please attach 010020.jpg if you want more help. Do it in your own post rather than in Gina's post from a year and a half ago.
If you don't see spikes in your fft, then there is probably no energy at certain special spatial frequencies.

サインインしてコメントする。

質問済み:

2017 年 2 月 22 日

コメント済み:

2018 年 9 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by