X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



9059 Rate this article:
3.0

Radially averaged Fourier Spectrum -- 2d


It is often necessary, when dealing with multidimensional data to compute the power spectrum as a function of |K|, the magnitude of the wavenumber vector. This is accomplished by computing the FFT and averaging power over circles of diameter |K|. Though fairly straightforward in theory, writing such a routine is often cumbersome because of details related to the arrangement of Fourier coefficients and the discrete representation of the circular average. Currently, such a routine is not part of IDL's standard math library.

Using the DIST and SHIFT functions together with FFT, this can be programmed extremely concisely in IDL. The basic code is given below.

IDL> array = dist(200,200)
IDL> pspec = powerspectrum(array)
IDL> plot, pspec, /ylog

;
; Function PowerSpectrum accepts a square 2D array as input
; and returns a 1D array that includes the Fourier power spectrum
; as a function of the waveVector magnitude, |K| = sqrt(kX*kX + kY*kY)
;
function PowerSpectrum, inputArray
sZ = SIZE(inputArray)
if (sZ[0] ne 2 or (sZ[0] eq 2 and sZ[1] ne sZ[2])) then begin
void = DIALOG_MESSAGE(/Error, ['Error in Power_Spectrum.',$
'Input needs to be a square 2D array.',$
'Calling sequence:',$
'outputSpectrum = PowerSpectrum(inputArray)'])
RETURN, inputArray
endif
nX = sZ[1] & nWaveNumber = nX / 2
waveNumberDist = SHIFT(DIST(nX), nWaveNumber, nWaveNumber)
fftArray = SHIFT(FFT(inputArray, -1), nWaveNumber, nWaveNumber)
fftArray = FLOAT(fftArray*CONJ(fftArray))
outputSpectrum = FLTARR(nWaveNumber)
for waveNumber = 0, nWaveNumber-1 do outputSpectrum[waveNumber] = $
TOTAL(fftArray[WHERE((waveNumberDist ge (waveNumber-0.5)) and $
(waveNumberDist lt (waveNumber+0.5)))])
RETURN, outputSpectrum
end
Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »