L_FFTBitmap

#include "l_bitmap.h"

L_INT EXT_FUNCTION 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. This function is available in the Raster Pro and above toolkits.

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 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, 32…etc). 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 signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

Required DLLs and Libraries

LTIMG

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 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_DFTBitmap, L_FrqFilterBitmap, L_FTDisplayBitmap, L_FrqFilterMaskBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_AddBitmapNoise, L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_AddShadowBitmap, L_ChangeHueSatIntBitmap, L_ColorThresholdBitmap, L_DFTBitmap, L_AllocFTArray, L_DirectionEdgeStatisticalBitmap, L_FFTBitmap, L_FreeFTArray, L_FrqFilterBitmap, L_FrqFilterMaskBitmap, L_GetBitmapStatisticsInfo, L_GetFeretsDiameter, L_GetObjectInfo, L_GetRgnContourPoints, L_GetRgnPerimeterLength, L_MathFunctionBitmap, L_RevEffectBitmap, L_SegmentBitmap, L_SubtractBackgroundBitmap, L_UserFilterBitmap, L_FragmentBitmap, L_HighPassFilterBitmap, L_UnsharpMaskBitmap

Topics:

Raster Image Functions: Fourier Transform

 

Removing Noise

Example

/* This example loads a bitmap and applies a FFT transformation. */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
pFTARRAY  pFTArray;

/* Load the bitmap, keeping the bits per pixel of the file */
L_LoadBitmap
(TEXT("IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);

/* Resize the bitmap to make sure the bitmap dimensions are power of two*/
L_SizeBitmap
(&LeadBitmap, 256, 512, SIZE_BICUBIC);

/* Allocate FFT buffer*/
L_AllocFTArray
(&LeadBitmap, &pFTArray, sizeof(FTARRAY));

/* Apply FFT*/
L_FFTBitmap
(&LeadBitmap, pFTArray, FFT_FFT | FFT_GRAY);

/* Free FFT buffer */
L_FreeFTArray
(pFTArray);