[Scilab-users] Re : fftshift and ifftshift are way too different
antoine monmayrant
antoine.monmayrant at laas.fr
Tue Oct 9 21:52:20 CEST 2018
Hello Samuel,
Sorry I might not have made myself clear: fft and fftshift provide the
ability to perform transform along only one of the dimensions of a
multidimensional array.
Something like S(x,y,z) --[FFT along 3rd dim]--> ffthift(ffft(S(x,y,z),
-1,3),3)=Ŝ(x,y,kz).
In that case, you need to perform fft and eventually fftshift along only
the dimension of the transform.
ifftshift should also provide the same possibility to perform the
inverse transform: Ŝ(x,y,kz) --[IFFT along 3rd dim]-->
iffthift(ffft(Ŝ(x,y,kz), +1,3),3)=S(x,y,z).
This is a basic signal processing requirement in my field.
Cheers,
Antoine
Le 09/10/2018 à 16:05, sgougeon at free.fr a écrit :
> Hello Antoine,
>
> fttshift() switches all halves along all dimensions. This is mandatory.
> So for instance in 2D, opposite quadrants (wrt the center) are switched.
> In 3D, opposite cubes are switched. etc.
>
> To me, the current implementation is right:
>
> --> m=grand(3,5,"uin",0,9)
> m =
> 2. 5. 9. 3. 0.
> 2. 4. 5. 5. 6.
> 4. 1. 8. 5. 9.
>
> --> fftshift(m)
> ans =
> 5. 9. 4. 1. 8.
> 3. 0. 2. 5. 9.
> 5. 6. 2. 4. 5.
>
> --> ifftshift(fftshift(m))
> ans =
> 2. 5. 9. 3. 0.
> 2. 4. 5. 5. 6.
> 4. 1. 8. 5. 9.
>
> --> and(ifftshift(fftshift(m))==m)
> ans =
> T
>
> BR
> Samuel
>
> ----- Mail d'origine -----
> De: antoine monmayrant+scilab <antoine.monmayrant+scilab at laas.fr>
> À: International users mailing list for Scilab. <users at lists.scilab.org>, List dedicated to development questions <dev at lists.scilab.org>
> Envoyé: Tue, 09 Oct 2018 11:02:20 +0200 (CEST)
> Objet: [Scilab-users] fftshift and ifftshift are way too different
>
> Hello all,
>
> From what I understand of fast Fourier transforms, fftshift and
> ifftshift should be almost identical.
> The only difference is when there are an odd number of elements in the
> dimension along which the shift is performed (ie
> fftshift([1:4])==ifftshift([1:4]) but fftshift([1:5])!=ifftshift([1:5])).
> However, it seems that in scilab6.x fftshift and ifftshift are based on
> completely different codes and do not accept the same arguments.
> In particular, with fftshift, one can specify the dimension along which
> to perform the shift, while it is not the case for ifftshift.
> I think some update of ifftshift would be welcome.
> I propose to use the code below (myifftshift), where I just changed
> "ceil" by "floor" in the definition if fftshift.
> What do you think, does it look right to you?
>
> Cheers,
>
> Antoine
>
> function x = myifftshift(x,job)
> if argn(2)<2 then job="all",end
> deff("sel=fun(sk)","c=floor(sk/2);sel=[c+1:sk,1:c]")
> if job=="r" then job=1,elseif job=="c" then job=2,end
> ind=list()
> if job=="all" then
> for sk=size(x),ind($+1)=fun(sk),end
> else
> for sk=size(x),ind($+1)=:,end;
> ind(job)=fun(size(x,job))
> end
> x=x(ind(:))
> endfunction
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
More information about the users
mailing list