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

Home » Public Forums » archive » Re: FFT+inverse FFT
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: FFT+inverse FFT [message #73885 is a reply to message #73883] Mon, 06 December 2010 07:10 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 6 déc, 15:16, Jeremy Bailin <astroco...@gmail.com> wrote:
> On Dec 5, 12:48 pm, Natalya Lyskova <natalya.lysk...@gmail.com> wrote:
>
>
>
>
>
>> Hey! I'm a beginner at IDL and have problem with FFT. I'm trying to
>> perform 2d-FFT but the code doesn't work properly even on test images.
>> So I create an image, make the Fourier transform, then the inverse
>> Fourier transform and finally I expect to get the initial image. But
>> the resulting image is the initial one, reversed with respect to the
>> center.
>
>> My code:
>> nx=256L
>> x1=findgen(nx)-nx/2.0+1.0
>> x2=findgen(nx)-nx/2.0+1.0
>
>> ytest=fltarr(nx,nx)
>> for i=0l,nx-1 do begin
>> for j=0l,nx-1 do begin
>>  if (x1[i] le 20.0 and x1[i] ge 0.0 and x2[j] le 20.0  and x2[j] ge
>> 0.0) then begin
>>     ytest[i,j]=1.0
>>  endif
>> endfor
>> endfor
>
>> ; So the initial image is a squre in the right upper corner
>
>> FFTtest=FFT(ytest)
>> sh_FFTtest=SHIFT(FFTtest,nx/2.0-1.0,nx/2.0-1.0)
>> inv_test=FFT(FFTtest,-1)
>
>> ;The result is the square in the LEFT LOWER corner.
>
>> I would be very grateful for comments/advices/solutions
>
>> Thank for help,
>> Natalya
>
> As a side note, a better (both faster and more readable) way of
> creating the original image instead of the double FOR loop is:
>
>  if (x1[i] le 20.0 and x1[i] ge 0.0 and x2[j] le 20.0  and x2[j] ge
> 0.0) then begin
>     ytest[i,j]=1.0
>
> upperright = where(x1 le 20.0 and x1 ge 0.0 and x2 le 20.0 and x2 ge
> 0.0, nupperright)
> if nupperright gt 0 then ytest[upperright]=1.0
>
> -Jeremy.- Masquer le texte des messages précédents -
>
Even simpler since IDL 8.0:

ytest[where(x1 le 20.0 and x1 ge 0.0 and x2 le 20.0 and x2 ge 0.0, /
NULL)]=1.0

alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Issue with the workbench menu
Next Topic: Re: Issue with the workbench menu

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

Current Time: Wed Oct 08 19:25:49 PDT 2025

Total time taken to generate the page: 0.00382 seconds