FFTShift - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

SignalProcessing

 FFTShift
 swap quadrants of arrays
 InverseFFTShift
 swap quadrants of arrays

 Calling Sequence FFTShift(A) FFTShift(A, dimension) InverseFFTShift(A) InverseFFTShift(A, dimension)

Parameters

 A - rtable dimension - integer, [integer], identical(all, "all", default, "default")

Description

 • The FFTShft(A) command swaps quadrants of A. It is usually applied to the Fourier Transform of a signal. In this case, it moves the zero-frequency elements to the center of A.
 • The InverseFFTShift(A) inverses the changes did by FFTShift and moves the zero-frequency elements back to the corner of A.
 • If FFTShift(A, dimension) is used, then InverseFFTShift(A, dimension) should be used with the same dimension.
 • For FFTShift(A, dimension), if dimension is provided as an integer, then A is split in half from the middle of the specified dimension, and these two parts are swapped. When the specified dimension is odd, the first half has one more layer of the specified dimension than the second half. dimension can also be a list of integers which means FFTShift would be applied to A for all the specified dimensions in the list. If dimension is specified as "all" or all, then A is swapped for all dimensions. If dimension is specified as "default" or default, and A is an image, then FFTShift will be applied to each layer and A would not be swapped for the last dimension. When A is not an image, specifying dimension to "all", all, "default" or default has the same effect. For an array with dimensions higher than 2, dimension must be specified. The default value for dimension is default.
 • InverseFFTShift command does almost the same thing as FFTShift, only for the odd dimension, the split is different: the first half has one layer fewer of the specified dimension than the second half.
 • If A is a one-dimensional Array with n elements, then FFTShift(A) swaps A[1..ceil(n/2)] (first half) with A[ceil(n/2)+1..n] (second half) and InverseFFTShift(A) swaps A[1..floor(n/2)] (first half) with A[floor(n/2)+1..n] (second half)
 • If A is an $m$ by $n$ Array or Matrix, then FFTShift(A) swaps A[1..ceil(m/2), 1..ceil(n/2)] (first quadrant) with A[ceil(m/2) + 1..m, ceil(n/2) + 1..n] (third quadrant) and A[1..ceil(m/2), ceil(n/2) + 1..n] (second quadrant) with A[ceil(m/2) + 1..m, 1..ceil(n/2)] (fourth quadrant). InverseFFTShift(A) does the same thing excepts for using $\mathrm{floor}$ instead of $\mathrm{ceil}$.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$
 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $A≔\mathrm{Vector}\left(5,\left[0.,2.,4.,-4.,-2.\right]\right)$
 $\left[\begin{array}{c}0.\\ 2.\\ 4.\\ -4.\\ -2.\end{array}\right]$ (4.1)
 > $\mathrm{A1}≔\mathrm{FFTShift}\left(A\right)$
 $\left[\begin{array}{c}-4.\\ -2.\\ 0.\\ 2.\\ 4.\end{array}\right]$ (4.2)
 > $\mathrm{InverseFFTShift}\left(\mathrm{A1}\right)$
 $\left[\begin{array}{c}0.\\ 2.\\ 4.\\ -4.\\ -2.\end{array}\right]$ (4.3)
 > $B≔\mathrm{Matrix}\left(1..3,1..3,\left(i,j\right)→j+3\left(i-1\right)\right)$
 $\left[\begin{array}{rrr}1& 2& 3\\ 4& 5& 6\\ 7& 8& 9\end{array}\right]$ (4.4)
 > $\mathrm{B1}≔\mathrm{FFTShift}\left(B\right)$
 $\left[\begin{array}{rrr}9& 7& 8\\ 3& 1& 2\\ 6& 4& 5\end{array}\right]$ (4.5)
 > $\mathrm{InverseFFTShift}\left(\mathrm{B1}\right)$
 $\left[\begin{array}{rrr}1& 2& 3\\ 4& 5& 6\\ 7& 8& 9\end{array}\right]$ (4.6)
 > $\mathrm{C1}≔\mathrm{Array}\left(1..2,1..2,1..2,\left(i,j,k\right)→j+2\left(i-1\right)+4\left(k-1\right)\right):$
 > ${\mathrm{C1}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),1}$
 $\left[\begin{array}{rr}1& 2\\ 3& 4\end{array}\right]$ (4.7)
 > ${\mathrm{C1}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),2}$
 $\left[\begin{array}{rr}5& 6\\ 7& 8\end{array}\right]$ (4.8)
 > $\mathrm{C2}≔\mathrm{FFTShift}\left(\mathrm{C1},2\right)$
 > ${\mathrm{C2}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),1}$
 $\left[\begin{array}{rr}2& 1\\ 4& 3\end{array}\right]$ (4.9)
 > ${\mathrm{C2}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),2}$
 $\left[\begin{array}{rr}6& 5\\ 8& 7\end{array}\right]$ (4.10)
 > $\mathrm{C3}≔\mathrm{InverseFFTShift}\left(\mathrm{C2},2\right)$
 > ${\mathrm{C3}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),1}$
 $\left[\begin{array}{rr}1& 2\\ 3& 4\end{array}\right]$ (4.11)
 > ${\mathrm{C3}}_{\left(\right)..\left(\right),\left(\right)..\left(\right),2}$
 $\left[\begin{array}{rr}5& 6\\ 7& 8\end{array}\right]$ (4.12)
 > $\mathrm{img}≔\mathrm{Read}\left(\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/tree.jpg"\right)\right):$
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{img}\right)\right)$

 > $\mathrm{img1}≔\mathrm{FFT}\left(\mathrm{img},\mathrm{dimension}=\left[1,2\right]\right):$
 > $\mathrm{img1}≔\mathrm{PowerSpectrum}\left(\mathrm{img1}\right):$
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{img1}\right)\right)$

 > $\mathrm{img2}≔\mathrm{FFTShift}\left(\mathrm{img1}\right):$
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{img2}\right)\right)$

 > $\mathrm{img3}≔\mathrm{InverseFFTShift}\left(\mathrm{img2}\right):$
 > $\mathrm{Embed}\left(\mathrm{img3}\right)$

Compatibility

 • The SignalProcessing[FFTShift] and SignalProcessing[InverseFFTShift] commands were introduced in Maple 2019.
 • For more information on Maple 2019 changes, see Updates in Maple 2019.

 See Also