2D IFFT
Compute 2D inverse fast Fourier transform (IFFT)
Libraries:
Computer Vision Toolbox /
Transforms
Description
The 2D IFFT block computes the inverse discrete Fourier transform (IDFT) of a twodimensional input matrix using the fast Fourier transform (FFT) algorithm. The equation for the 2D IDFT f(x, y) of an MbyN input matrix, F(m, n), is:
$$f(x,y)=\frac{1}{MN}{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}F(m,n){e}^{j\frac{2\pi mx}{M}}}}{e}^{j\frac{2\pi ny}{N}},$$
where $$0\le x\le M1$$ and $$0\le y\le N1$$.
The block supports FFT implementation based on the FFTW library and an implementation based on a collection of Radix2 algorithms. You can either manually select one of these implementations or let the block select one automatically.
Examples
Ports
Input
Port_1 — Input data
vector  matrix
Input data, specified as a vector or matrix of intensity values.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
 fixed point
Complex Number Support: Yes
Output
Port_1 — Output data
vector  matrix
Output data containing the 2D IFFT of the input, returned as a vector or matrix. The size and data type of the output are the same as those of the input.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
 fixed point
Complex Number Support: Yes
Parameters
Main
FFT implementation — FFT implementation
Auto
(default)  Radix2
 FFTW
Specify the type of implementation to compute the FFT as one of these options:
FFTW
— Select this option to use to support an arbitrarylength input signal. The block restricts generated code with theFFTW
implementation to host computers capable of running MATLAB^{®}.Radix2
— Select this option to support bitreversed processing, fixed and floatingpoint data, or portable Ccode generation using Simulink Coder. The dimensions of the input matrix, M and N, must be powers of two. To work with other input sizes, use the Image Pad block to pad or truncate these dimensions to powers of two, or, if possible, choose theFFTW
implementation. For more information about the algorithms used by theRadix2
mode, see Radix2 Implementation.Auto
— Select this option to let the block choose the FFT implementation. For nonpoweroftwo transform lengths, the block restricts generated code to MATLAB host computers.
Input is in bitreversed order — Bitreversed input
off
(default)  on
Specify whether the input to the block is in bitreversed order or linear order. Select this parameter when you specify the input in bitreversed order. Otherwise, clear this parameter. The block yields invalid output when you do not set this parameter correctly. For more information on the bitreversed order of input, see BitReversed Order.
Dependencies
To enable this parameter, set the FFT implementation
parameter to Auto
or
Radix2
.
Input is conjugate symmetric — Conjugate symmetric input
on
(default)  off
Select this parameter to specify that the block input is conjugate symmetric, and you want realvalued outputs. Otherwise, clear this parameter.
The 2D FFT block yields conjugate symmetric output when you input realvalued data. Taking the 2D IFFT of a conjugate symmetric input matrix produces realvalued output. Therefore, if the input to the 2D IFFT block is conjugate symmetric, and you select this parameter, the block produces realvalued outputs. When you select this parameter, the block optimizes its computation method. You cannot select this parameter for fixedpoint.
If you specify conjugate symmetric input data and do not select this parameter, the block outputs complexvalued data with small imaginary parts. The block outputs invalid data if you select this parameter with input data that is not conjugate symmetric input data.
Divide output by product of FFT length in each input dimension — Scale output data
on
(default)  off
Select this parameter to compute the scaled IFFT, which divides the output by the product of the dimension lengths of the FFT input dimension, as shown in this equation.
$$f(x,y)=\frac{1}{MN}{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}F(m,n){e}^{j\frac{2\pi mx}{M}}}}{e}^{j\frac{2\pi ny}{N}},$$
where $$0\le x\le M1$$ and $$0\le y\le N1$$.
When you clear this parameter, the block computes the unscaled version of the IFFT, as shown in this equation.
$$f(x,y)={\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}F(m,n){e}^{j\frac{2\pi mx}{M}}}}{e}^{j\frac{2\pi ny}{N}}$$
Data Types
For details on the fixedpoint block parameters, see Specify FixedPoint Attributes for Blocks (DSP System Toolbox).
Lock data type settings against change by the fixedpoint tools — Data type override
off
(default)  on
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify in this block. For more information, see Lock the Output Data Type Setting (FixedPoint Designer).
Block Characteristics
Data Types 

Multidimensional Signals 

VariableSize Signals 

More About
BitReversed Order
Two numbers are bitreversed values of each other when the binary representation of one
is the mirror image of the binary representation of the other. For example, in a threebit
system, one and four are bitreversed values of each other because the threebit binary
representation of one, 001
, is the mirror image of the threebit binary
representation of four, 100
. The diagram shows the row indices in linear
order. To put them in bitreversed order:
Translate the indices into their binary representations with the minimum number of bits. In this example, the minimum number of bits is three because the binary representation of the largest row index, 7, is
111
.Find the mirror image of each binary entry, and write it beside the original binary representation.
Translate each binary mirror image to its decimal representation.
The row indices now appear in bitreversed order.
When you select the Output in bitreversed order parameter of the 2D FFT block, the block bitreverses the order of both the rows and columns. All output values remain the same, but they appear in a different order.
FixedPoint Data Types
These diagrams show the data types used in the 2D FFT block for fixedpoint signals. The block first casts inputs to the output data type and stores them in the output buffer. Each butterfly stage then processes signals in the accumulator data type, with the final butterfly casting its output back into the output data type. The block multiplies by a twiddle factor before each butterfly stage, in a decimationintime FFT, and after each butterfly stage in a decimationinfrequency FFT.
The multiplier output appears in the accumulator data type because both of the inputs to the multiplier are complex. For details on the complex multiplication performed, refer to Multiplication Data Types.
Algorithms
FFTW Implementation
The FFTW implementation provides an optimized FFT calculation, including support for poweroftwo and nonpoweroftwo transform lengths in both simulation and code generation. Generated code using the FFTW implementation can run only on computers capable of running MATLAB. The input must be of a floatingpoint data type.
Radix2 Implementation
The Radix2 implementation supports bitreversed processing, fixed or floatingpoint data, and enables the block to provide portable Ccode generation using Simulink Coder. The dimensions of the input matrix, M and N, must be powers of two. To work with other input sizes, use the Image Pad block to pad or truncate these dimensions to powers of two.
The block implements one or more of these algorithms for Radix2 implementation.
Butterfly operation
Doublesignal algorithm
Halflength algorithm
Radix2 decimationintime (DIT) algorithm
Radix2 decimationinfrequency (DIF) algorithm
Parameter Settings  Algorithms Used for FFT Computation 

 Bitreversed operation and radix2 DIT 
 Radix2 DIF 
 Bitreversed operation and radix2 DIT in conjunction with the halflength and doublesignal algorithms 
 Radix2 DIF in conjunction with the halflength and doublesignal algorithms 
Note
The Input is conjugate symmetric parameter is not supported for fixedpoint signals.
In certain situations, the Radix2 algorithm computes all the possible trigonometric values of the twiddle factor:
$${e}^{j\frac{2\pi k}{K}},$$
where K is the greater value of either
M or N, and k is an integer in
the range [0
, K – 1
]. The block
stores these values in a table and retrieves them during simulation. This table summarizes
the number of table entries each for fixedpoint and floatingpoint Radix2 FFT
algorithms:
Number of Table Entries for NPoint FFT  

Floating point  3N/4 
Fixed point  N 
References
[1] “FFTW Home Page.” Accessed February 23, 2022. https://www.fftw.org/.
[2] Frigo, M., and S.G. Johnson. “FFTW: An Adaptive Software Architecture for the FFT.” In Proceedings of the 1998 IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP ’98 (Cat. No.98CH36181), 3:1381–84. Seattle, WA, USA: IEEE, 1998. https://doi.org/10.1109/ICASSP.1998.681704.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Usage notes and limitations:
When these conditions apply, the executable generated from this block relies on prebuilt dynamic library files (
.dll
files) included with MATLAB:FFT implementation is set to
FFTW
.Inherit FFT length from input dimensions is cleared, and the length of each dimension of the input matrix is a power of two.
Use the
packNGo
function to package the code generated from this block and all the relevant files in a compressed ZIP file. Using this ZIP file, you can relocate, unpack, and rebuild your project in another development environment where MATLAB is not installed.When the length of each dimension of the input matrix is a power of two, you can generate standalone C and C++ code from this block.
Version History
Introduced before R2006a
See Also
Blocks
 2D FFT  2D DCT  2D IDCT  2D FIR Filter
Functions
fft2
ifft2
bitrevorder
(Signal Processing Toolbox)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)