Skip to main content
Please wait...
Using the Inverse Fast Fourier Transform (ifft) in CNN Models
01 Jun, 2025

Using the Inverse Fast Fourier Transform (ifft) in CNN Models

Fast Fourier Transform (FFT) and Discrete Fourier Transform (DFT) 

The Discrete Fourier Transform (DFT) converts a sequence of time-domain samples into frequency-domain components:

$$ X_k = \sum{n=0}^{N-1} x_n \cdot e^{-2\pi i kn/N} $$

This operation has a time complexity of $O(N^2)$, which becomes computationally expensive for large $N$.

The Fast Fourier Transform (FFT) is an efficient algorithm to compute the DFT in $ O(N \log N) $ time. It exploits symmetries in the DFT matrix, particularly when $ N $ is a power of 2, using a divide-and-conquer approach. 

 

Cooley–Tukey FFT Algorithm 

The Cooley–Tukey algorithm is the most common FFT method. It divides the DFT into even and odd indexed parts:

$$ X_k = E_k + e^{-2\pi i k/N} \cdot O_k $$

Where:

  • $E_k$ is the DFT of even-indexed inputs

  • $O_k$ is the DFT of odd-indexed inputs

This divide-and-conquer approach is efficient when $N$ is a power of 2.

  

FFT Example: Photovoltaic Data 

In photovoltaic systems, FFT can extract frequency components from power output data to detect: 

  • Daily solar cycles 

  • Shading patterns 

  • Inverter switching noise 

Example: Applying FFT to a time series of solar panel output reveals dominant frequencies corresponding to sunlight variation and electrical noise. 

 

Fast Fourier Convolution (FFC) 

Fast Fourier Convolution uses the convolution theorem: $ f * g = \text{IFFT}(\text{FFT}(f) \cdot \text{FFT}(g)) $ This is used in image processing to apply large convolution kernels efficiently. 

 

Neural Networks and CNNs 

A neural network is a computational model inspired by the brain, consisting of layers of interconnected nodes (neurons). 

Convolutional Neural Networks (CNNs) are specialized for grid-like data (e.g., images). They use: 

  • Convolutional layers to extract features 

  • Pooling layers to reduce dimensionality 

  • Fully connected layers for classification 

 

Role of Convolutional Kernels 

The convolutional kernel (or filter) slides over the input image to detect patterns like edges, textures, or shapes. It learns to extract hierarchical features during training. 

 

Why CNNs Excel at Vision Tasks 

CNNs are effective because they: 

  • Capture spatial hierarchies 

  • Share weights (reducing parameters) 

  • Are translation invariant 

 

CNNs for mm-Wave Pilot Signals 

A real-world architecture uses CNNs to process the raw data of broadband mm-Wave pilot signals for channel estimation and hybrid beamforming in MIMO-OFDM systems[2][1]

 

Real-World CNN Example: Feature Extraction 

In medical imaging, CNNs extract features from MRI scans to classify tumors. The network learns to detect shapes, textures, and anomalies. 

 

Inverse Fast Fourier Transform (IFFT) 

IFFT converts frequency-domain data back to the time domain. In MATLAB: 

x = [1, 2, 3, 4]; 
X = fft(x); 
x_reconstructed = ifft(X);

 

IFFT Example: MRI k-Space Reconstruction

MRI scanners collect data in k-space. Applying IFFT reconstructs the spatial image. 

Here’s a simulated example: 

MRI k-space FFT and IFFT, Picture 

 

Frequency Domain Block: FFT → High-Pass Filter → IFFT

This block: 

  • FFT: Converts image to frequency domain 

  • High-pass filter: Removes low-frequency (smooth) components 

  • IFFT: Reconstructs image with enhanced edges 

This is effective for feature enhancement before feeding into CNNs. 

 

Example: Deep Integrated CNN Architecture with Frequency Filtering 

Architecture Overview: 

  • Input: Grayscale image (e.g., handwritten digit) 

  • Preprocessing: FFT → High-pass filter → IFFT 

  • CNN: Small 3×3 kernels for feature extraction 

  • Output: Classification (e.g., digit label) 

 

Code Example (TensorFlow & PyTorch) 

TensorFlow 

import tensorflow as tf 
import numpy as np 
 
def high_pass_filter(freq_data): 
    mask = np.ones(freq_data.shape) 
    center = tuple(map(lambda x: x // 2, freq_data.shape)) 
    mask[center[0]-5:center[0]+5, center[1]-5:center[1]+5] = 0 
    return freq_data * mask 
 
def preprocess_image(image): 
    fft = tf.signal.fft2d(tf.cast(image, tf.complex64)) 
    filtered = high_pass_filter(fft.numpy()) 
    ifft = tf.signal.ifft2d(tf.convert_to_tensor(filtered)) 
    return tf.math.abs(ifft) 
 
# Example CNN 
model = tf.keras.Sequential([ 
    tf.keras.layers.Conv2D(16, (3, 3), activation='relu', input_shape=(28, 28, 1)), 
    tf.keras.layers.Flatten(), 
    tf.keras.layers.Dense(10, activation='softmax') 
])

PyTorch 

import torch 
import torch.nn as nn 
import torch.fft 
 
def high_pass_filter(freq_data): 
    mask = torch.ones_like(freq_data) 
    c = freq_data.shape[-1] // 2 
    mask[..., c-5:c+5, c-5:c+5] = 0 
    return freq_data * mask 
 
def preprocess_image(image): 
    fft = torch.fft.fft2(image) 
    filtered = high_pass_filter(fft) 
    ifft = torch.fft.ifft2(filtered) 
    return ifft.abs() 
 
class SimpleCNN(nn.Module): 
    def __init__(self): 
        super().__init__() 
        self.conv = nn.Conv2d(1, 16, kernel_size=3) 
        self.fc = nn.Linear(26*26*16, 10) 
 
    def forward(self, x): 
        x = torch.relu(self.conv(x)) 
        x = x.view(x.size(0), -1) 
        return torch.softmax(self.fc(x), dim=1) 

 

References 

[3] BOSE, ANURAG. Generative Image Rectifier. Diss. University of Calcutta, 2023. 

[4] Yin, Yi, et al. "Research on multi-source microstructure image recognition of foam ceramics using convolutional network combine with frequency domain." Scientific Reports 15.1 (2025): 3032. 

[5] Palvanov, Akmaljon, and Young Im Cho. "Visnet: Deep convolutional neural networks for forecasting atmospheric visibility." Sensors 19.6 (2019): 1343. 

[6] Liu, Huajun, et al. "Long-Term Time Series Forecasting With Time-Frequency Interleaving Representation Network." Available at SSRN 4998564. 

[7] Elbir, Ahmet M., et al. "A family of deep learning architectures for channel estimation and hybrid beamforming in multi-carrier mm-wave massive MIMO." IEEE Transactions on Cognitive Communications and Networking 8.2 (2021): 642-656. 

[8] Ullah, Nadeem, et al. "DCDA-Net: dual-convolutional dual-attention network for obstructive sleep apnea diagnosis from single-lead electrocardiograms." Engineering Applications of Artificial Intelligence 123 (2023): 106451. 

[9] Šimon, Ondřej, and Tomáš Götthans. "A Survey on the Use of Deep Learning Techniques for UAV Jamming and Deception" Electronics 11, no. 19: 3025. https://doi.org/10.3390/electronics11193025 (2022) 

[10] Zhang, Bingxian, et al. "GFRENet: An Efficient Network for Underwater Image Enhancement with Gated Linear Units and Fast Fourier Convolution." Journal of Marine Science and Engineering 12.7 (2024): 1175.