LEADTOOLS Raster Imaging C++ Class Library Help > Classes and Member Functions > LBitmap > LBitmap Member Functions > LBitmap::FFT |
#include "ltwrappr.h"
virtual L_INT LBitmap::FFT (pFTArray, uFlags)
pFTARRAY pFTArray; |
/* pointer to an FTARRAY structure */ |
L_UINT uFlags; |
/* flags */ |
Computes the Fast Fourier transform of an image or the Inverse Fast Fourier transform as specified in the uFlags.
Parameter |
Description |
|
pFTArray |
Pointer to FTARRAY structure. The acxData member of the FTARRAY structure is a two-dimensional array that will hold the frequency components of the image. Its size must be the same as the image. The function will fill the array elements using data from pBitmap when FFT_FFT flag is passed. The function will use the array values and reconstruct pBitmap when FFT_IFFT flag is passed. |
|
uFlags |
Flags that indicate the transformation type, operation channel, frequency data type used to reconstruct the image, and the clipping type. You can use a bit-wise OR (|) to specify one flag from each group. |
|
|
The following flags represent the transformation type: |
|
|
Value |
Meaning |
|
FFT_FFT |
[0x0001] Convert the image into frequency domain and store the results in the acxData. |
|
FFT_IFFT |
[0x0002] Construct an image from the frequency components in acxData. The image will be stored in pBitmap. This option will change the values of acxData. |
|
The following flags represent the operation channel type: |
|
|
Value |
Meaning |
|
FFT_BLUE |
[0x0010] Work on the blue channel. |
|
FFT_GREEN |
[0x0020] Work on the green channel. |
|
FFT_RED |
[0x0030] Work on the red channel. |
|
FFT_GRAY |
[0x0040] Work on the master Channel. If this flag is combined with FFT_IFFT, the reconstructed image will be gray. |
|
The following flags represent the frequency data type used for constructing the image: this flag is used only if FFT_IFFT is set and will be ignored if FT_FFT is set: |
|
|
Value |
Meaning |
|
FFT_IFFT_MAG |
[0x0100] Construct the image from the frequency magnitude only. |
|
FFT_IFFT_PHS |
[0x0200] Construct the image from the frequency phase only. |
|
FFT_IFFT_BOTH |
[0x0300] Construct the image from both magnitude and phase. |
|
The following flags represent the clipping type. This flag is used only if FFT_IFFT is set and will be ignored if FFT_FFT is set: |
|
|
Value |
Meaning |
|
FFT_IFFT_CLIP |
[0x1000] Clip the constructed image values to be between 0 and 255. |
|
FFT_IFFT_SCL |
[0x2000] Scale the constructed image Valid values are between 0 and 255. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function converts the image from the time domain to the frequency domain and vice versa using a Fast Fourier Transform algorithm. Fast Fourier Transform algorithms are a simplification of a Discrete Fourier Transform and require that the image dimensions must be power of two (i.e. 2, 4, 8, 16, 32etc). The number of computations needed are reduced from 2N2 to 2N LgN. Use the LBitmap::DFT to use a Discrete Fourier Transform algorithm on a bitmap. If you try to use this function with a bitmap with dimensions that are not a power of two, the function will return an ERROR_INV_PARAMETER error.
Before using this function, call the LBitmap::AllocFTArray function to allocate a FTARRAY structure large enough to hold the Fourier Transform coefficients for pBitmap. When the array is no longer needed, free the allocated array by calling the LBitmap::FreeFTArray function.
This function does not work on regions. If a bitmap has a region the function ignores it and processes the entire bitmap.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Required DLLs and Libraries
LTIMGCOR For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64.
See Also
Example
L_INT LBitmap__FFTExample(LBitmap *pLeadBitmap) { L_INT nRet; /* This example loads a bitmap and applies a FFT transformation. */ pFTARRAY pFTArray; /* Resize the bitmap to make sure the bitmap dimensions are power of two*/ nRet =pLeadBitmap->Size (256, 512, SIZE_BICUBIC); if(nRet !=SUCCESS) return nRet; /* Allocate FFT buffer*/ nRet =pLeadBitmap->AllocFTArray (&pFTArray, sizeof(FTARRAY)); if(nRet !=SUCCESS) return nRet; /* Apply FFT*/ nRet =pLeadBitmap->FFT( pFTArray, FFT_FFT | FFT_GRAY); if(nRet !=SUCCESS) return nRet; /* : : Free FFT buffer */ nRet =LBitmap::FreeFTArray (pFTArray); if(nRet !=SUCCESS) return nRet; return SUCCESS; }