# 4.3.6 2D FFT and Filter

## Summary

2D FFT (2-dimensional Fast Fourier Transform) can be used to analyze the frequency spectrum of 2D signal (matrix) data. Conversely, 2D IFFT (2-dimension Inverse Fast Fourier Transform) is able to reconstruct a 2D signal from a 2D frequency spectrum. OriginPro provides both for conversion between time and frequency domains in 2 dimensions, together with the 2D FFT filter to perform filtering on a 2D signal.

## What You Will Learn

This tutorial will show you how to:

1. Convert image into data.
2. Perform 2D FFT on matrix data with DC shift to center.
3. Perform 2D IFFT on the 2D FFT result to recover the original matrix data.
4. Perform 2D FFT filter on matrix data.

## Steps

### 2D FFT

1. Start with a new matrixbook, and select menu item Data: Import from File: Image to Matrix... to import the image <Origin Installation Directory>\Samples\Image Processing and Analysis\cell.jpg.
2. Because Origin is not able to perform analyses on image data directly, we need to convert the image to matrix data first. So, select menu item Image: Conversion: Convert to Data to bring up the Convert to Data: img2m dialog box. Set Type to byte(1).
3. Click OK to finish the conversion. The result shows below. You can choose menu item View: Data Mode and View: Image Mode to convert between data mode and image mode.
4. With the converted result matrix active, select the menu item Analysis: Signal Processing: FFT: 2D FFT... to open the 2D FFT: fft2 dialog box. Check the DC Shift Center check box to shift the direct current to center. In the Output node, only check Complex Matrix and Log Amplitude Matrix.
5. Click the OK button to generate the FFT results. Both the complex matrix and the log amplitude matrix are in the same matrixbook. Change to image mode (View:Image Mode) for the log amplitude matrix. The results should look like this:

### 2D IFFT

1. Start with the complex matrix (FFT2_Complex1) generated in the 2D FFT section above. Make it the active window.
2. Select the menu item Analysis: Signal Processing: FFT: 2D IFFT... to bring up the 2DIFFT: ifft2 dialog box.
3. In the dialog box, the imaginary matrix is not needed because the Input Matrix is a complex matrix. Check Undo Shift because DC has been shifted. Output should have the Real Matrix and Imaginary Matrix boxes checked.
4. Click the OK button, and the result will be output to the same matrixbook as the input complex matrix.
5. From the comparison shown below, the IFFT has recovered the original signal.

### 2D FFT Filter

1. Start with an empty matrixbook and from the menu select Data: Import from File: Image to Matrix... to import the image <Origin Installation Directory>\Samples\Image Processing and Analysis\myocyte1.tif.
2. With the imported image active. select the menu item Image: Conversion: Convert to Data. This opens the Convert to Data: img2m dialog box. Set Type to byte(1) and click OK to finish the conversion.
3. Activate the converted matrix and select the menu item Analysis: Signal Processing: 2D FFT Filters.... This opens the 2D FFT Filters: fft_filter2 dialog box.
4. In the dialog box, check the Auto Preview check box at the bottom to view the result in the right panel. Set Filter Type to Band Pass, and set Lower Cutoff Value and Upper Cutoff Value to 0.05 and 0.25 respectively. For other controls, keep the default values.
5. Click OK to obtain the filtered result. As the image below shows, the background noise (the light) is removed.