Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to compute the power spectrum slope of an image?

Subject: how to compute the power spectrum slope of an image?

From: Shaojie

Date: 23 Feb, 2009 03:58:01

Message: 1 of 5

% I is a NxN image
% first compute the power spectrum of the image
fftI=fftshift(fft2(I));
Suv=fftI.*conj(fftI)/prod(size(I));
----
then, how to sum the power spectrum over all orientation and obtain the slope?
Thanks!

Subject: how to compute the power spectrum slope of an image?

From: Bjorn Gustavsson

Date: 23 Feb, 2009 09:26:02

Message: 2 of 5

"Shaojie " <zarachis@gmail.com> wrote in message <gnt6s9$p7r$1@fred.mathworks.com>...
> % I is a NxN image
> % first compute the power spectrum of the image
> fftI=fftshift(fft2(I));
> Suv=fftI.*conj(fftI)/prod(size(I));
> ----
> then, how to sum the power spectrum over all orientation and obtain the slope?
> Thanks!
>
I'd try something like this

f_x = [-size(I,2)/2:(size(I,2)/2-1)];
f_y = [-size(I,1)/2:(size(I,1)/2-1)];
[f_x,f_y] = meshgrid(f_x,f_y);
Pf_r = polyfit(abs(fftl(:)).^2,(f_x(:).^2+f_y(:).^2).^.5,1);

you'd better check that the DC component gets to the right point...

HTH,
Bjoern

Subject: how to compute the power spectrum slope of an image?

From: Shaojie

Date: 23 Feb, 2009 14:07:02

Message: 3 of 5

"Bjorn Gustavsson" <bjonr@irf.se> wrote in message <gntq3a$r49$1@fred.mathworks.com>...
> "Shaojie " <zarachis@gmail.com> wrote in message <gnt6s9$p7r$1@fred.mathworks.com>...
> > % I is a NxN image
> > % first compute the power spectrum of the image
> > fftI=fftshift(fft2(I));
> > Suv=fftI.*conj(fftI)/prod(size(I));
> > ----
> > then, how to sum the power spectrum over all orientation and obtain the slope?
> > Thanks!
> >
> I'd try something like this
>
> f_x = [-size(I,2)/2:(size(I,2)/2-1)];
> f_y = [-size(I,1)/2:(size(I,1)/2-1)];
> [f_x,f_y] = meshgrid(f_x,f_y);
> Pf_r = polyfit(abs(fftl(:)).^2,(f_x(:).^2+f_y(:).^2).^.5,1);
>
> you'd better check that the DC component gets to the right point...
>
> HTH,
> Bjoern
don't understand, would you pls explain it,thanks!

the definition of slope is:
first compute the fft and power spectrum,
S(u,v)=FFT(I)/N^2
then, represent them in polar coordinate and sum them over all directions:
S(f)=sum_theta{S(f,theta)}.=Af^(-alpha)
the *alpha* is called the slope of power spectrum and it is what i want to estimate

Subject: how to compute the power spectrum slope of an image?

From: Bjorn Gustavsson

Date: 23 Feb, 2009 15:03:02

Message: 4 of 5

"Shaojie " <zarachis@gmail.com> wrote in message <gnuai6$clg$1@fred.mathworks.com>...
> "Bjorn Gustavsson" <bjonr@irf.se> wrote in message <gntq3a$r49$1@fred.mathworks.com>...
> > "Shaojie " <zarachis@gmail.com> wrote in message <gnt6s9$p7r$1@fred.mathworks.com>...
> > > % I is a NxN image
> > > % first compute the power spectrum of the image
> > > fftI=fftshift(fft2(I));
> > > Suv=fftI.*conj(fftI)/prod(size(I));
> > > ----
> > > then, how to sum the power spectrum over all orientation and obtain the slope?
> > > Thanks!
> > >
> > I'd try something like this
> >
> > f_x = [-size(I,2)/2:(size(I,2)/2-1)];
> > f_y = [-size(I,1)/2:(size(I,1)/2-1)];
> > [f_x,f_y] = meshgrid(f_x,f_y);
> > Pf_r = polyfit(abs(fftl(:)).^2,(f_x(:).^2+f_y(:).^2).^.5,1);
> >
> > you'd better check that the DC component gets to the right point...
> >
> > HTH,
> > Bjoern
> don't understand, would you pls explain it,thanks!
>
> the definition of slope is:
> first compute the fft and power spectrum,
> S(u,v)=FFT(I)/N^2
> then, represent them in polar coordinate and sum them over all directions:
> S(f)=sum_theta{S(f,theta)}.=Af^(-alpha)
> the *alpha* is called the slope of power spectrum and it is what i want to estimate
>
Oh, I see. I'd thunk that would be the exponent, guess I missguessed then. In my suggested solution I happily avoided reinterpolating the fft, since that adds discretization-type "noise" - and I honestly don't know how to do optimally. (Others might come with more detailed insight on this point.) Thus I just made a direct polynomial fit to the 2-D fft as a function of "radial" frequency. This should be identical, possibly with a factor of f_R off in my solution.

If you want the exponent then you could do something like this instead of my direct polyfit:
P = polyfit(log((f_x(:).^2+f_y(:).^2).^.5),log(abs(fftl(:))),1)
Further, maybe you should add some frequency-dependent weight to the log(abs(fftI)) as well.


HTH,
Bjoern

Subject: how to compute the power spectrum slope of an image?

From: Carsten

Date: 18 Nov, 2013 00:14:16

Message: 5 of 5

> > > "Shaojie " <zarachis@gmail.com> wrote in message <gnt6s9$p7r$1@fred.mathworks.com>...
> > > > % I is a NxN image
> > > > % first compute the power spectrum of the image
> > > > fftI=fftshift(fft2(I));
> > > > Suv=fftI.*conj(fftI)/prod(size(I));
> > > > ----
> > > > then, how to sum the power spectrum over all orientation and obtain the slope?
> > > > Thanks!
> > > >

Dear Shaojie,
I know this reply is "a bit" late and I guess you already solved the problem, but maybe other people are still interested in that topic. A very clear implementation of Power Spectrum Slope for images in Matlab is given here:

http://redwood.berkeley.edu/bruno/npb261b/lab2/lab2.html

Carsten

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us