
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - ifftn() Function
The scipy.fft.ifftn() method gives the N-dimensional Inverse Fast Fourier Transform for complex data by transforming frequency domain data to spatial or time domain on 1D, 2D, 3D or more.
This method is extensively used in reconstructing multi-dimensional signals that are in the form of 2D pictures and 3D volumetric data-for instance, in the field of medical imaging. It is suited for applications requiring higher-dimensional data.
The ifftn method is a generalized IFFT for N-dimensions, that include 2D, 3D, and more so it is applicable to multidimensional data. In contrast, ifft handles a 1D data input like time series. Whereas, ifft2 specifically deals with 2-dimensional data like pictures or matrices.
Syntax
The syntax for the SciPy ifftn() method is as follows −
.ifftn(x, s=None, axes=None, norm=None, overwrite_x=False, workers=None, *, plan=None)
Parameters
This method accepts the following parameters −
x (array_like) − Input array (can be complex) representing data in the frequency domain.
s (sequence of ints, optional) − Shape of the output along each transformed axis. Pads with zeros or truncates the input.
axes (sequence of ints, optional) − Axes over which to compute the IFFT. Defaults to all axes.
norm (str, optional) − The normalization mode allows control over scaling: "backward" (default, no scaling), "ortho" (unitary scaling for energy preservation), and "forward" (scales the output by 1/n, where n is the transform length).
overwrite_x (bool, optional) − If True, allows the input array x to be overwritten for better performance. Default is False.
workers (str, optional) − Number of parallel workers to use for computation. Default is None, meaning a single thread is used.
plan (optional) − Precomputed plan for FFT optimization (advanced use). Default is None.
Return Value
out The N-dimensional IFFT result, representing reconstructed data in the spatial or time domain.
Example 1
This is an example of a simple reconstruction of the data. This is performed first by transforming the data to the frequency domain through FFT fftn() and then returning to the original spatial domain through the IFFT ifftn().
import numpy as np from scipy.fft import fftn, ifftn # Create a 2D array x = np.array([[1, 2], [3, 4]]) # Perform FFT and then IFFT freq = fftn(x) reconstructed = ifftn(freq).real print("Reconstructed Data:\n", reconstructed)
When we run above program, it produces following result
Reconstructed Data: [[1. 2.] [3. 4.]]
Example 2
The below code creates an image with specific frequency content by specifying a small set of active frequencies in a 2D frequency domain. These frequencies are translated back into the spatial domain by ifftn() method, and the result is a periodic pattern in the image.
The output is a grayscale image with patterns matching to the frequencies that were triggered. Narrow frequency bands produce grid-like periodic structures, illustrating how changes in the frequency domain are translated into spatial domain images.
import numpy as np import matplotlib.pyplot as plt from scipy.fft import ifftn # Create a band-limited frequency domain n = np.zeros((200, 200), dtype=complex) # Create a 2D frequency domain with zeros n[50:70, 30:50] = np.exp(1j * np.random.uniform(0, 2 * np.pi, (20, 20))) # Add random phase content # Transform back to the spatial domain using Inverse FFT im = ifftn(n).real # Plot the resulting image plt.imshow(im, cmap='gray') plt.title("Image with Band-Limited Frequency Content") plt.colorbar() plt.show()