Power Spectral Density Figure
2 views (last 30 days)
Show older comments
Hi all,
I've spent the better part of two days flailing at this, so I figured it's time to ask. I have a set of images, and I need to calculate the average power at several saptial frequencies such I can derive an average for the entire set of images. The article I am trying to follow said "The spatial frequency content of images used in the experiment was analyzed by computing a periodogram with overlapping Hamming windows (a power spectral density estimate using the Welch’s method in the MATLAB image processing toolbox, averaged over horizontal and vertical dimensions.) Their resulting figure is (note, thre are 4 sets of images in this figure, each a unique color):

I know there are myriad threads on similar questions, but I just can't seem to piece together the process for getting this type of plot. Any help is appreciated.
14 Comments
Bjorn Gustavsson
on 30 Jan 2021
Sure, this is what I did to make my illustration:
x = 1:128;
[x,y] = meshgrid(x);
kx = [-64:63];
[kx,ky] = meshgrid(kx);
I1 = sin(x/128*2*pi*16) + sin(y/128*2*pi*8);
I2 = sin((x-y)/2^.5/128*2*pi*16) + sin((y+x)/2^.5/128*2*pi*8);
fI2 = fft2(I2);
fI1 = fft2(I1);
asfI2 = (abs(fftshift(fI2)));
asfI1 = (abs(fftshift(fI1)));
subplot(2,3,1)
imagesc(I1)
subplot(2,3,4)
imagesc(I2)
subplot(2,3,2)
pcolor(kx-1/2,ky-1/2,log10(asfI1)),shading flat,set(gca,'TickDir','out')
subplot(2,3,5)
pcolor(kx-1/2,ky-1/2,log10(asfI2)),shading flat,set(gca,'TickDir','out')
subplot(2,3,3)
plot(kx(1,65:end),asfI1(65,65:end),'.-')
hold on
plot(ky(65:end,1),asfI1(65:end,65),'.-')
set(gca,'YScale','log','XScale','log')
subplot(2,3,6)
plot(kx(1,65:end),asfI2(65,65:end),'.-')
hold on
plot(ky(65:end,1),asfI2(65:end,65),'.-')
You can just add the amplitudes (or amplitudes squared) of the FFTs from the images together and plot the horizontal and vertical components - the DC ones. If you don't do the fftshift operation you'll find them on the first row and column of the fft:
fI = fft2(Im);
A_hor = abs(fI(1,1:end/2));
A_ver = abs(fI(1:end/2,1));
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

