Re: 2D FFT help [message #32442] |
Tue, 08 October 2002 13:41 |
Stein Vidar Hagfors H[1]
Messages: 56 Registered: February 2000
|
Member |
|
|
Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
> Greetings all,
>
> I am trying to perform a multi-dimensional FFT in IDL. I thought I had
> this figured out (example 1) but I am now feeling (example 2) that this
[..]
> ; Shift the array (correct element 0 being the zero frequency component)
> b_fixed = shift(b, -1*64, -1*64)
[..]
> ; Shift the array (correct element 0 being the zero frequency component)
> spec_fixed = shift(spec_cov, -1*64, -1*64)
[..]
> So, in the first case, the answer looks correct and is a slight deviation
> from the standard textbook example of the FFT of a cylinder. In the second
> case, however, the results looks to be rotated by 90 degrees in the plane,
> i.e. I think the result and input should look identical. Can someone
> explain what I have done wrong? I am also somewhat troubled by the spike
> currently at (0,0)?
The two IDL lines above are slightly wrong... After the fft, [0,0] contains
the zero frequency component, so if you want to shift it to pixel [n/2,n/2],
you should do "just that", i.e.:
b_fixed = shift(b,64,64)
spec_fixed = shift(spec_cov,64,64)
Note that the choice of n/2 versus n/2-1 as a "center point" may seem
arbitrary for visualization purposes (there's no *center* of a 2^n-sized
array!). However, if you choose n/2-1 instead, (i.e. shift(..,63,63)), you're
making sure that the (degenerate) highest-frequency point (found at [64,64] in
the original fft result) does not get wrapped around to [0,0], so this is
obviously the correct choice.
The rotation by 90 degrees is exactly as it should be. Just think: what would
a 1d transform of the line along the diagonal look like? A single entry at 0
frequency, right? Well, that's what you get if you "integrate away 1
dimension" (summing strips that are normal to your original line, collapsing
2d to 1d). Works in both domains!!
--
------------------------------------------------------------ --------------
Stein Vidar Hagfors Haugan
ESA SOHO SOC/European Space Agency Science Operations Coordinator for SOHO
NASA Goddard Space Flight Center, Email: shaugan@esa.nascom.nasa.gov
Mail Code 682.3, Bld. 26, Room G-1, Tel.: 1-301-286-9028/240-354-6066
Greenbelt, Maryland 20771, USA. Fax: 1-301-286-0264
------------------------------------------------------------ --------------
|
|
|
Re: 2D FFT help [message #32446 is a reply to message #32442] |
Tue, 08 October 2002 09:37  |
Randall Skelton
Messages: 169 Registered: October 2000
|
Senior Member |
|
|
On Tue, 8 Oct 2002, Randall Skelton wrote:
> So, in the first case, the answer looks correct and is a slight deviation
> from the standard textbook example of the FFT of a cylinder. In the second
> case, however, the results looks to be rotated by 90 degrees in the plane,
> i.e. I think the result and input should look identical. Can someone
> explain what I have done wrong? I am also somewhat troubled by the spike
> currently at (0,0)?
I take back what I wrote above... it seems my intuition was wrong... the
story of my week.
Cheers,
Randall
|
|
|