Fourier transform is a method of transferring signals from the time domain into the frequency domain. It is mostly used to convert the frequency domain into a time domain.
The scipy.fft.ifft2
is a Python function to perform inverse Fourier Transform of the 2-D FFT. The inverse of the 2-dimensional signals is provided in the Scientific Python (SciPy) library.
The basic syntax of the function is as follows:
# Import fft package from scipy libraryimport scipy.fft# Perform ifft2 on the input signal to get the Inverse of the 2D Fourier Transformfft = scipy.fft.ifft2(signal)
The scipy.fft.ifft2
performs Fast Fourier Transform (FFT), which is designed as a computationally efficient version of Fourier Transform. FFT improves speed by decreasing the number of calculations needed to analyze a waveform. The complete syntax scipy.fft.ifft2
with details on arguments is given below:
scipy.fft.ifft2(x, s=None, axes=(- 2, - 1),norm=None, overwrite_x=False, workers=None, *,plan=None)[source]
x
: The input array containing real or complex values of the signal.
s
: The sequence of ints, represents the shape of the output. Its default is the shape of specified axes. It is an optional parameter.
axes
: The sequence of integers pointing the axes over which to compute the FFT. Default axes are the last two. It is an optional parameter.
norm
: Normalization to apply to the signal. {default = “backward”, “ortho”, “forward”}. It is an optional parameter.
overwrite_x
: Boolean value to decide whether to perform FFT in-place. The default value is false. It is an optional parameter.
workers
: The integer value that represents the maximum number of workers allowed for parallel computing. It is an optional parameter.
out
: A complex array containing the transformation of the input array around the specified axes.
An interesting example of this function is to compute the FFT of the 2-dimensional extension of a sinusoidal wave called sinusoidal grating. And then apply fft2
on that signal to compute its frequency components. Also, apply ifft2
on the components to regenerate the original signal.
A sinusoidal grating can be viewed as a grayscale image in which the values change according to the sine function.
Sinusoidal grating: It shows a horizontal grating in which the grayscale along the x-axis varies according to the amplitude of the sine wave.
Fourier Transform: It shows the corresponding Fourier transform identifying the presence of a signal.
Inverse of Fourier transform: It shows the inverse of the Fourier Transformation.
Below is a jupyter notebook for a hands-on experience to create combinations of gratings and compute their Fourier Transform using the scipy.fft.fft
. Then compute the Inverse of the Fourier Transform using scipy.fft.ifft2
.