Trusted answers to developer questions

Namra Ijlal

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

**Fourier transform** is a method of transferring signals from the time domain into frequency. It is mostly used to identify the components of a signal.

The `scipy.fft.fft2`

function is provided by the Scientific Python (SciPy) library to perform Fourier transform on 2D signals.

The basic syntax of this function is as follows:

# Import fft package from scipy libraryimport scipy.fft# Perform fft2 on the input signal to get 2D Fourier Transformfft = scipy.fft.fft2(signal)

Basic syntax of the "scipy.fft.fft2" function

The `scipy.fft.fft2`

function 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 of the `scipy.fft.fft2`

function is:

scipy.fft.fft2(x, s=None, axes=(- 2, - 1), norm=None,overwrite_x=False, workers=None, *, plan=None)

Complete syntax of the "scipy.fft.fft2" function

: This is the input array that contains real or complex values of the signal.`x`

: This is the sequence of ints that represents the shape of the output. The default value of this parameter is the shape of specified axes. This is an optional parameter value.`s`

: This is the sequence of integers that point to the axes over which to compute the FFT. The default axes are the last two. This is an optional parameter value.`axes`

: Normalization to apply to the signal. {default = “backward”, “ortho”, “forward”}. This is an optional parameter value.`norm`

: This is a boolean value that decides whether to perform FFT in-place or not. The default value of this parameter is`overwrite_x`

`false`

. This is an optional parameter value.: This is the integer value that represents the maximum number of workers allowed for parallel computing. This is an optional parameter value.`workers`

This function returns `out`

, which is a complex array that contains the transformation of the input array around the specified axes.

An interesting example of this function is to compute the FFT of the 2D extension of a sinusoidal wave called sinusoidal grating.

A **sinusoidal grating** can be viewed as a grayscale image in which the values change according to the sine function. The figure on the left shows a horizontal grating in which the grayscale along the x-axis varies according to the amplitude of the sine wave. The figure on the right shows the corresponding Fourier transform identifying the presence of a signal.

Given below is a Jupyter notebook for gaining hands-on experience with creating combinations of gratings and computing their Fourier transform using the scipy.fft.fft2 function.

RELATED TAGS

fft2

scipy

communitycreator

python

CONTRIBUTOR

Namra Ijlal

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses