L_FFTBitmap
#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_FFTBitmap(pBitmap, pFTArray, uFlags)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
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 |
|
pBitmap |
Pointer to the bitmap handle that references the bitmap, object of the transformation. |
|
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 does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
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 L_DFTBitmap 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 L_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 L_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 L_SetStatusCallback.
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. |
Platforms
Windows 2000 / XP/Vista.
See Also
Example
This example loads a bitmap and applies a FFT transformation.
L_INT FFTBitmapExample(L_VOID) { L_INT nRet; BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */ pFTARRAY pFTArray; /* Load the bitmap, keeping the bits per pixel of the file */ nRet = L_LoadBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet !=SUCCESS) return nRet; /* Resize the bitmap to make sure the bitmap dimensions are power of two*/ nRet = L_SizeBitmap(&LeadBitmap, 256, 512, SIZE_BICUBIC); if(nRet !=SUCCESS) return nRet; /* Allocate FFT buffer*/ nRet = L_AllocFTArray(&LeadBitmap, &pFTArray, sizeof(FTARRAY)); if(nRet !=SUCCESS) return nRet; /* Apply FFT*/ nRet = L_FFTBitmap(&LeadBitmap, pFTArray, FFT_FFT | FFT_GRAY); if(nRet !=SUCCESS) return nRet; /* Free FFT buffer */ nRet = L_FreeFTArray(pFTArray); if(nRet !=SUCCESS) return nRet; nRet = L_SaveBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL); if(nRet !=SUCCESS) return nRet; //free bitmap if(LeadBitmap.Flags.Allocated) L_FreeBitmap(&LeadBitmap); return SUCCESS; }