File Exchange

image thumbnail

Radially averaged power spectrum of 2D real-valued matrix

version 1.5.0.0 (2.09 KB) by Evan Ruzanski
Computes and plots radially averaged PSD of 2-D real matrix with a given spatial resolution.

16 Downloads

Updated 17 Mar 2011

View License

The radially averaged power spectrum (RAPS) is the direction-independent mean spectrum, i.e. the average of all possible directional power spectra. The radially averaged power spectrum provides a convenient means to view and compare information contained in 2-D spectra in 1-D. This function computes and plots the RAPS of an input matrix (does not consider corner values outside averaging radius). The image can be rectangular but must be 2-D (e.g., multi-color channel data is not supported). The spatial resolution of the data is also specified.

Comments and Ratings (12)

sj

Hi, very useful code,
what does res mean?. is it actual pixel size?

very helpful, thanks

f e

Thanks

Amos

Jim Kasson

Joao Marcos

Also, even my region is ~1000km the spectrum shows energy up to 5000km...

Joao Marcos

Thank you for the file, it was very usefull.
I runned a test where I linearly interpolate a 50km wind data to 5km. I would expect a drop in the energy at 100km, but the spectra shows eenrgy cascating down to the 5km scale. Do you know why this happens?
Thank you

fong

useful for understanding RAPSD to analysis the spectral characteristics of a halftone pattern?

for r = 0:floor(dimMax/2)
i{r + 1} = find(rho == r);
end
Pf = zeros(1, floor(dimMax/2)+1);
for r = 0:floor(dimMax/2)
Pf(1, r + 1) = nanmean( imgfp( i{r+1} ) );
end
there is some bug in this part

Stefano

Hi, I found this to be faster, hope it helps, S.
%% code for fast radial averaging:
[xx,yy]=meshgrid(-1000:1000,-1000:1000);
rr=sqrt(xx.^2+yy.^2);
ri=floor(rr/100)+1;
N=numel(ri);
[~,~,iir]=unique(ri); %find unique values
Qt =sparse(1:N,iir,ones(N,1));

tic;Pf=(rr(:).'*Qt).';toc %radial average

Updates

1.5.0.0

Clarified restrictions on input to the file description (e.g., multi-channel data from JPG, etc. is not supported)

1.4.0.0

Added feature to handle odd/even dimensionality differences of input matrix

1.3.0.0

Fixed bug in x-axis of plot; preallocated memory for axes label cells; removed minor ticks from y-axis; cleaned up comments.

1.2.0.0

Rectangular matrices can now be input; spatial resolution can be specified.

1.1.0.0

The radially averaged power spectrum provides a convenient means to view and compare information contained in 2D spectra in 1D.

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux