Fast Fourier Transformation (FFT)
Contents
 1 Filtering images
 1.1 Background
 1.1.1 Finite Impulse Response (FIR) filters with Hamming windows
 1.1.2 Gaussian and Butterworth filters
 1.1.3 Image types
 1.1.4 Special notes
 1.1.5 References
 1.2 Applying the FFT algorithm
 1.2.1 Step 1: Converting dataset from spatial to fourier domain using the forward FFT command
 1.2.2 Step 2: Enhancing and attenuating frequency components using Frequency Filter
 1.2.3 Optional Step: Attenuating frequency components using the Paint tool
 1.2.4 Step 3: Reconverting the image to the spatial domain
 1.1 Background
 2 See also:
Filtering images
There are two main approaches to filtering an image. The first is the convolution of an image and kernel in the spatial domain. The second is the multiplication of an image's Fourier transform with a filter in the frequency domain. The Fast Fourier transformation (FFT) algorithm, which is an example of the second approach, is used to obtain a frequencyfiltered version of an image. Processing images by filtering in the frequency domain is a threestep process:
 Perform a forward fast Fourier transform to convert a spatial image to its complex fourier transform image. The complex image shows the magnitude frequency components. It does not display phase information.
 Enhance selected frequency components of the image and attenuate other frequency components of the image by multiplying by a lowpass, highpass, bandpass, or bandstop filter. In MIPAV, you can construct frequency filters using one of three methods: finite impulse response filters constructed with Hamming windows, Gaussian filters, and Butterworth filters. However, for the Gaussian filters, only lowpass and highpass filters are available.
 Perform an inverse fast fourier transform to reconvert the image from the frequency domain to the spatial domain.
You can also use Algorithms > Filters (frequency) to obtain a frequencyfiltered version of an image in a single step. A contrast of the FFT and Filter (frequency) commands on the Algorithms menu is helpful in determining which one to select.
Use . . .

To . . .


Algorithms > Filters (frequency)

Obtain a frequencyfiltered version of an image in a single step. All three steps in the process are performed internally and only the resultant filtered image is displayed.

Algorithms > FFT

Produce pictures of the fourier transform of the image and the filtered fourier transform of the image.

Background
Fast Fourier Transformation (FFT) algorithm:background;
Since all dimensions of an ndimensional dataset must be powers of 2, datasets with arbitrary dimensions are zero padded to powers of 2 before applying the Fast Fourier Transform and stripped down to the original dimensions after applying the Inverse Fast Fourier Transform.
If real source data is used, then the output obtained after the final Inverse Fast Fourier Transform step is purely real, no matter what filter construction method is used. Any nonzero imaginary part present after the Inverse Fast Fourier Transform is due to Randolph error. Hence, the imaginary part is discarded and only the real part is imported into the final image. Figure 1 shows the application of the FFT algorithm to a 2D image.
In MIPAV, frequency filters may be constructed using one of three methods: finite impulse response filters constructed with Hamming windows, Gaussian filters, and Butterworth filters. You select the method when you enter the parameters for the algorithm.
Finite Impulse Response (FIR) filters with Hamming windows
If you use FIR filters with Hamming windows, an ideal filter kernel is constructed in the spatial domain. A Hamming window kernel is also constructed in the spatial domain. Then, the ideal filter kernel and the Hamming window kernel are multiplied together in the spatial domain. The resultant kernel is a circle or odd diameter sphere with its center at (kernel diameter  1)/2 in every dimension. The kernel is zero padded up to the same dimensions as the original image data.
The two fourier transforms (image and filter) are multiplied, and the inverse fourier transform is obtained. The result is a filtered version of the original image shifted by (kernel diameter  1)/2 toward the end of each dimension. The data is shifted back by (kernel diameter  1)/2 to the start of each dimension before the image is stripped to the original dimensions.
In every dimension the length of the resulting fourier image must be greater than or equal to the length of nonzero image data kernel diameter  1 so that aliasing does not occur. In aliasing, higher frequency components incorrectly shift to lower frequencies. Thus, if the image is not cropped, each frequency space dimension must be greater than or equal to the minimum power of two that equals or exceeds the original dimension size kernel diameter 1. If cropping is selected, the fourier image is only increased to the minimum power of 2 that equals or exceeds the original dimension size rather than the minimum power 2 that equals or exceeds the original dimension size kernel diameter  1. With cropping, a band of pixels at the boundaries of the image is set equal to 0. A power of 2 increase in dimension length is avoided at the cost of losing edge pixels.
The following formula defines the discretespace fourier transform pair:
<math> X(\omega_1, \omega_2) = \sum_{n_{1} =\infty}^\infty \sum_{n_2=\infty}^\infty x(n_1,n_2)e^{j\omega_1 n_1} e^{j\omega_2n_2} </math>
<math> x(n_1n_2) = \frac {1}{(2\pi)^2}\int_{\omega_1}^\pi=\pi\int_{w_2}^\pi=\pi^{X(\omega_1,\omega_2) e^{j\omega_1 n_1}e^{j\omega_2 n_2}}\partial\omega_1\partial\omega_2 </math>
While centering is invoked in FFT to provide a clearer display, centering is not used in frequency filter where no fourier images are produced.
Gaussian and Butterworth filters
In the frequency filtering step, both the real and imaginary parts of the fourier transform are scaled by the same formula, which depends only on the distance from the center of image.
The FIR filter must create two fourier transforms: one for the original image and one for the kernel. The Butterworth and Gaussian filters only need to create one fourier transform for the image since frequency scaling is done with a formula. Therefore, the FIR filter uses about twice as much memory as the Gaussian or Butterworth filters.
Centering is needed for the Gaussian and Butterworth filters since the scaling formulas are based on frequency magnitude increasing from the center of the image.
Butterworth 2D and 3D filters
 Butterworth filters:2D;
 Butterworth filters:3D;
 Butterworth filters:2D;
The following are the formulas for the Butterworth 2D and 3D filters, respectively.'
<math> distsq = \frac {(xxcenter)^2}{(xcenter)^2} + \frac {(yycenter)^2}{(ycenter)^2} </math>
<math> distsq = \frac {(xxcenter)^2}{(xcenter)^2} + \frac {(yycenter)^2}{(ycenter)^2}+ \frac {(zzcenter)^2}{(zcenter)^2} </math>
The real data is the product of the real data and the coefficient. The imaginary data is the product of the imaginary data and the coefficient.
Butterworth lowpass, highpass, bandpass, and bandstop filters
 Butterworth filters:highpass;
 Butterworth filters:lowpass;
 Butterworth filters:bandstop;
 Butterworth filters:bandstop;
 Butterworth filters:highpass;
The following are the equations for the Butterworth lowpass, highpass, bandpass, and bandstop filters.
Butterworth lowpass filter
<math> coefficient = \frac {1}{1 +\left ( \frac {distsq}{(f_1)} \right )^{2butterworthorder}} </math>
Highpass filter
<math> coefficient = \frac {1}{1 +\left ( \frac {(f_1)}{distsq} \right )^{2butterworthorder}} </math>
Bandpass filter
<math> width = f_2f_1centersq = f_1f_2 </math>
<math> num = (distsqcentersq)^{2butterworthorder} </math>
<math> coeff = \frac {num} {(num + (distsqcentersq)^{2butterworthorder})} </math>
Bandstop filter
<math> width = f_2=f_1,centersq= f_1f_2 </math>
<math> num = ({\sqrt distsq}{width})^{2butterworthorder} </math>
<math> coeff= \frac {num} {\left ( num + ({\sqrt distsq}{width})^{2butterworthorder} \right )} </math>
Gaussian low and highpass filters
The following equations are for the Gaussian low and highpass filters.
Gaussian lowpass (2D)
<math> coefficientforgaussianhighpass= 1gaussianlowpass </math>
Gaussian lowpass (3D)
<math> coefficient = {e^{\frac {(xxcenter)^2}{(2f^2xcenter^2)}}}{e^{\frac {(yycenter)^2} {(2f^2ycenter^2)}}} {e^{\frac {(zzcenter)^2} {(2f^2zcenter^2)}}} </math>
Note: The routine bessj1 for determining a bessel function of the first kind and first order is taken from "Numerical Recipes in C." 
 i.routine bessj1;
 i.routine bessj1;
Image types
 Fast Fourier Transformation (FFT) algorithm:image types;
 image types:Fast Fourier Transformation (FFT) algorithm;
 Fast Fourier Transformation (FFT) algorithm:image types;
You cannot apply a forward FFT to complex data. However, you can apply the frequency filter or perform an inverse FFT on conjugate, symmetric, and complex data. You cannot apply this algorithm to Alpha Red Green Blue (ARGB) datasets, but you can apply it to other grayscale 2D and 3D images.
Special notes
By default, the resultant image is a floattype image. Intermediate fourier transform images and filtered fourier transform images obtained in FFT are complex images.
References
 Fast Fourier Transformation (FFT) algorithm:references ;
 Fast Fourier Transformation (FFT) algorithm:references ;
Refer to the following references for more information about this algorithm:
Nasir. Ahmed, DiscreteTime Signals and Systems (Reston, Virginia: Reston Publication Company, 1983), pp. 243258.
Raphael C. Gonzalez and Richard E. Woods. Digital Image Processing (Boston: AddisonWesley, 1992), pp. 201213, 244.
Jae S. Lim and Joe S. Lim, TwoDimensional Signal and Image Processing (Upper Saddle River, New Jersey: PrenticeHall PTR, 1990), pp. 5758, 195213.
William H. Press, Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling, "Numerical Recipes in C," The Art of Scientific Computing, Second Edition (Cambridge, Massachusetts: Cambridge University Press, p. 1993), pp. 233, 521525.
Applying the FFT algorithm
 Fast Fourier Transformation (FFT) algorithm:applying;
 applying:FFT algorithm;
 Fast Fourier Transformation (FFT) algorithm:applying;
Generally, when an image is filtered in the frequency domain, you use the following threestep process:
 Apply Forward FFT. In this first step, the spatial image is converted to a complex fourier transform image.
 Apply Frequency Filter: Next, you can enhance and attenuate selected frequency components by multiplying the fourier transform image by the lowpass, highpass, bandpass, or bandstop filters.
 Apply Inverse FFT: Finally, you can perform an inverse fast fourier transform to reconvert the image to the spatial domain.
You can use the FFT algorithm to perform one or all of these steps.
Step 1: Converting dataset from spatial to fourier domain using the forward FFT command
 commands:format FFT;
 converting dataset from spatial to fourier domain;
 forward FFT command;
 image dataset:converting from spatial to fourier domain;
 commands:format FFT;
To convert the dataset from the spatial to fourier domain, complete the following steps:
 In the Default Image window, open a dataset that is displayed in the spatial domain.
 In the MIPAV window, select Algorithm > FFT. The FFT dialog box opens (Figure 2).
 Select the destination.
 By default, the forward FFT is selected. (The frequency filter and inverse FFT methods cannot be applied to real spatial datasets.)
 Select the filter construction method. If you select the Butterworth filter, enter the order.
 FIR: Click Windowed finite impulse response. Enter the kernel diameter, which must be an odd number that is greater than or equal to 3. To save memory at the expense of zeroing edge pixels, select or clear image cropping.
 Gaussian: Click Gaussian filter.
 Butterworth: Click Butterworth filter, and then enter the order of the Butterworth filter.
 Having selected the filter construction method, you can choose to apply the following options:
 If you select Display log magnitude, the log10 [1 square root (real part**2 imaginary part**2)] is shown. If the Display log magnitude is clear, square root (real part**2 imaginary part**2) is shown.
 If your image has unequal dimensions, you can select Allow unequal FFT dimensions to allow unequal FFT dimensions. If you want the FFT to equalize the dimensions to produce a symmetrical image, clear the check box.
 If you selected the FIR filter, you can crop the image to save memory. Enter an odd number for the convolution kernel diameter. The number must be odd so there is symmetry around a center point.
 Click OK to perform the forward FFT. MIPAV applies the FFT algorithm. When complete, the fourier transform of the image appears.
Step 2: Enhancing and attenuating frequency components using Frequency Filter
 frequency components:enhancing and attenuating ;
 enhancing and attenuating frequency components;
 frequency components:enhancing and attenuating ;
To apply the frequency option to enhance and attenuate frequency components, complete the following steps:
 Select the fourier transform of a spatial image. The image appears in a default image window.
 In the MIPAV window, select Algorithms > FFT. The FFT dialog box (Figure 2) opens.
 Select the destination.
 Select Frequency Filter.
 Click, if desired, the check box to display the log magnitude.
 Select one of the following filter specifications:
 Lowpass: Type the value of the frequency. The value must be greater than 0.0, but less than or equal to 1.0. where 0.0 is the zero frequency and 1.0 is the absolute value of the frequency at the end of a centered fourier dimension.
 Highpass: Enter the value of the frequency. The value must be greater than 0.0, but less than or equal to 1.0. 0.0 is the zero frequency, 1.0 is the absolute value of the frequency at the end of a centered fourier dimension.
 Bandpass: Type the values of the frequencies F1 and F2, with F2 greater than F1. The value must be greater than 0.0, but less than or equal to 1.0 where 0.0 is the zero frequency and 1.0 is the absolute value of the frequency at the end of a centered fourier dimension.
 Bandstop: Enter the values of the frequencies F1 and F2, with F2 greater than F1. The value must be greater than 0.0, but less than or equal to 1.0 where 0.0 is the zero frequency and 1.0 is the absolute value of the frequency at the end of a centered fourier dimension.
 When complete, click OK. MIPAV applies the FFT algorithm. When complete, the fourier transform of the image appears.
Process each slice independently (2.5D)

Filters each slice of the dataset independently of adjacent slices.


Display log magnitude

Displays 1 plus the magnitude of the FFT.
 
Allow unequal FFT dimensions

Allows the image to have unequal dimensions. If this option is not selected, FFT makes the dimensions equal, which may result in more memory usage during processing.
 
Windowed finite impulse response

Constructs an ideal filter kernel and a Hamming window kernel in the spatial domain and multiplies them. The resultant kernel is a circle or sphere of odd diameter with its center at (kernel diameter 1)/2 in every dimension.
 
Crop image to save memory

Saves memory by assigning the edge pixels of the image a value of zero.
 
Convolution kernel diameterodd

Limits the diameter of the convolution kernel to the size that you specify.
 
Gaussian filter

Applies the Gaussian filter to the image. The Gaussian filters only lowpass and highpass filters are available.
 
Butterworth filter

Applies the Butterworth filter, which has a maximally flat response in its passband. The passband is the range of frequencies that pass with a minimum of attenuation through an electronic filter.
 
Order

Displays the order of the Butterworth filter.
 
New image

Places the result of the algorithm in a new image window.
 
Replace image

Replaces the current active image with the results of the algorithm.
 
Forward FFT

Converts spatial image to a complex fourier transform image.
 
Frequency filter

Enhances or attenuates selected frequency components by multiplying the fourier transform image by the lowpass, highpass, bandpass, or bandstop filters.
 
Lowpass

Suppresses frequencies above a specified threshold. Frequencies below the threshold are transmitted.
 
Highpass

Suppresses frequencies below a specified threshold. Frequencies above the threshold are transmitted.
 
Bandpass

Suppresses all frequencies except those in a specified band.
 
Bandstop

Suppresses a band of frequencies from being transmitted through the filter. Frequencies above and below the band are transmitted.
 
OK

Applies the FFT algorithm according to the specifications in this dialog box.
 
Cancel

Disregards any changes that you made in this dialog box and closes the dialog box.
 
Help

Displays online help for this dialog box.

Optional Step: Attenuating frequency components using the Paint tool
With the Paint tool you can attenuate frequency components to values whose magnitude is 1,000 times the minimum floating point value. The values are not simply attenuated to zero because this would result in the phase information being lost and cause phase discontinuities in the image. Frequency components whose magnitudes are less than or equal to 1,000 times the minimum floating point value are unaffected by the paint tool. To do this, complete the following steps:
 Display the paint toolbar if it is not already visible. To do this, in the MIPAV window, select Toolsbar > Paint toolbar. The paint toolbar appears.
 Select Paint Brush to select the paint brush.
 Select the size of the paint brush tip. Choose one of the following:
 As you draw, you can select one pixel at a time or drag to draw paint strokes on the image.
Note: In painting complex images, the complex image is assumed to have been generated from real data. x(n1,n2) real < > X(k1,k2) = X*(k1,k2) for 2D and x(n1,n2,n3) real <> X(k1,k2,k3) = X*(k1,k2,k3). Thus, real data yields a conjugate symmetric fourier transform. Therefore, when one pixel is painted in a complex image, its conjugate symmetric pixel is also painted. As you draw in 2D, the paint also appears on the opposite side of the image. As you draw in 3D, the paint also appears on the opposite side of the image on another slice. This mirroring technique ensures that, when the inverse fourier transform is applied to the frequency image, the spatial image that results is purely real. 
 conjugate symmetric fourier transform;
 image:complex, mirroring technique used in drawing;
 conjugate symmetric fourier transform;
 When finished, to return to normal mode, click Normal Mode.
 You can erase the paint from the image's paint layer by completing the following steps. You can either erase all paint from the image or erase paint from a specific conjugate symmetric area.
 To erase space from a specific area, complete the following steps

 Click Erase.
 Select the size of the eraser tip. Click Small Tip to select a tip that is 1 pixel in size. Click Medium Tip to select a tip that is 16 pixels (4 x 4 square) in size. Click Large Tip to select a tip that is 100 pixels (10 x 10 square) in size.
 Use the mouse to begin erasing. You can select one pixel at a time or drag the mouse. If desired, use the magnification buttons to magnify the image.
 When finished, to return to normal mode, click Normal Mode.
 Click Commit to commit the changes (copy them permanently to an image).
Step 3: Reconverting the image to the spatial domain
To reconvert the image to the spatial domain, complete the following steps:
 Select the fourier transform of a spatial image. The image appears in a default image window.
 In the MIPAV window, select Algorithms > FFT. The FFT dialog box
(Figure 2) opens.  Select the destination.
 Select Inverse FFT.
 If desired, click Display log magnitude.
 Click OK. When complete processing is complete, the image appears in the spatial domain.
See also:
 Using MIPAV Algorithms
 Cost functions used in MIPAV algorithms
 Interpolation methods used in MIPAV
 Degrees of freedom
 Filters (Spatial): Adaptive Noise Reduction
 Filters (Frequency)
 Filters (Spatial): Adaptive Path Smooth
 Filters (Spatial) Anisotropic Diffusion
 Filters (Spatial): CoherenceEnhancing Diffusion
 Filters (Spatial): Gaussian Blur
 Filters (Spatial): Gradient Magnitude
 Filters (Spatial) Laplacian
 Filters (Spatial) Local Normalization
 Filters (Spatial): Mean
 Filters (Spatial): Median
 Filters (Spatial): Mode
 Filters (Spatial): Nonlinear Noise Reduction
 Filters (Spatial): Nonmaximum Suppression
 Filters (Spatial): Regularized Isotropic (Nonlinear) Diffusion
 Filters (Spatial): Slice Averaging
 Filters (Spatial): Unsharp Mask
 Filters (Wavelet): Thresholding