# 2-D FFT

Compute 2-D fast Fourier transform (FFT)

Libraries:
Computer Vision Toolbox / Transforms

## Description

The 2-D FFT block computes the discrete Fourier transform (DFT) of a two-dimensional input matrix using the fast Fourier transform (FFT) algorithm. The equation for the two-dimensional DFT F(m, n) of an M-by-N input matrix, f(x, y), is:

`$F\left(m,n\right)=\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}f\left(x,y\right){e}^{-j\frac{2\pi mx}{M}}{e}^{-j\frac{2\pi ny}{N}}$`

where $0\le m\le M-1$ and $0\le n\le N-1$.

The block supports FFT implementation based on the FFTW library and an implementation based on a collection of Radix-2 algorithms. You can either manually select one of these implementations or let the block select one automatically.

## Ports

### Input

expand all

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

expand all

Output data containing the 2-D FFT 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

expand all

### Main

Specify the type of implementation to use to compute the FFT as one of these options:

• `FFTW` — Select this option to support an arbitrary-length input signal. The block restricts generated code with the `FFTW` implementation to host computers capable of running MATLAB®.

• `Radix-2` — Select this option to support bit-reversed processing, fixed and floating-point data, or portable C-code 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 the `FFTW` implementation. For more information about the algorithms used by the `Radix-2` mode, see Radix-2 Implementation.

• `Auto` — Select this option to let the block choose the FFT implementation. For non-power-of-two transform lengths, the block restricts generated code to MATLAB host computers.

Select this parameter to get the output data in bit-reversed order relative to the order of the input data. If you clear this parameter, the output data appears in linear order relative to the order of the input data. For more information on the bit-reversed order of output, see Bit-Reversed Order.

#### Dependencies

To enable this parameter, set the FFT implementation parameter to `Auto` or `Radix-2`.

When you select this parameter, the block divides the output by the FFT length. This option is useful when you want the output of the FFT to stay in the same amplitude range as its input. This is particularly useful when working with fixed-point data types.

### Data Types

For details on the fixed-point block parameters, see Specify Fixed-Point Attributes for Blocks (DSP System Toolbox).

Select this parameter to prevent the fixed-point tools from overriding the data types you specify in this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).

## Block Characteristics

 Data Types `double` | `fixed point` | `integer` | `single` Multidimensional Signals `no` Variable-Size Signals `yes`

expand all

expand all

## References

[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.

## Version History

Introduced before R2006a