comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Again an FFT question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Again an FFT question [message #80652 is a reply to message #80650] Wed, 27 June 2012 09:22 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 26 juin, 23:11, Helder <hel...@marchetto.de> wrote:
> Dear FFTers,
> I was just wondering about the translation of the FFT so that the what is located at (0,0) goes in the middle of the image (N/2,M/2).
> Until now I did this doing simply a shift of the FFT image, that is:
> FFT_Img = SHIFT(FFT(Img),N/2,M/2)
> Now I have seen that some people use a FFT "trick" to shift the image. They switch every second pixel of an image to its negative value. This is justified by the translation properties of the DFTs and results in a translation of half the image size (for those seeking to understand the math, try to multiply the function (image) by exp(i*2*Pi(u0*x/N)) and after integration you will get a translation of the Fourier image (signal for 1D) of F(u-u0).
>
> I have tested the difference between the two shifting methods with the following code (in double precision just to be sure I wouldn't get rounding errors or so):
> ;**************************
> n = 256
> img = RANDOMU(S, n, n) ; Eventually put your image here, with the *right* size
> xx = LINDGEN(n) # (LONARR(n)+ 1)
> yy = (LONARR(n)+ 1) # LINDGEN(n)
> xxyy = xx+yy
> OddCenteredImg = Img
> EvenCenteredImg = Img
> Odd = WHERE((xxyy MOD 2), COMPLEMENT=Even)
> OddCenteredImg[Odd] = -Img[Odd]
> EvenCenteredImg[Even] = -Img[Even]
> WINDOW, XSIZE=2*n,YSIZE=3*n
> TVSCL, Img, 0   ;Transform by standard shifting
> TVSCL, OddCenteredImg, 1   ;Transform by standard shifting
> TVSCL, ALOG(ABS(SHIFT(FFT(Img,/DOUBLE),n/2,n/2))), 2   ;Transform by standard shifting
> TVSCL, ALOG(ABS(FFT(OddCenteredImg, /DOUBLE))), 3     ;Transform by pixel sign inversion
> TVSCL, ALOG(ABS(SHIFT(FFT(Img,/DOUBLE),n/2,n/2)) - ABS(FFT(OddCenteredImg, /DOUBLE))), 4  ;Power Spectrum Image Difference
> TVSCL, ALOG(ABS(SHIFT(FFT(Img,/DOUBLE),n/2,n/2)) - ABS(FFT(EvenCenteredImg, /DOUBLE))), 5  ;Power Spectrum Image Difference
> ;**************************
>
> The result is that the two are not exactly the same. Very similar, but not the same.
> I have tried varying the size of the image or switching even instead of odd numbers index numbers , but could not get any improvement (with odd image sizes, the difference is even higher).
>
> Does anybody have a reason to use one way (shift(fft(Img...))) rather than the other (switch pixels with index ((x+y) MOD 2 EQ 1)?
>
> I'm more confident using SHIFT, but I would just like to understand why the other method gives different values.
>
> Thanks,
> Helder
>
>

You can use the /CENTER keyword in FFT function since IDL7.1
alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problem in the path
Next Topic: Re: problem in the path

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:21:23 PDT 2025

Total time taken to generate the page: 0.00403 seconds