L_DFTBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_DFTBitmap (pBitmap, pFTArray, prcRange, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

pFTARRAY pFTArray;

pointer to a structure

RECT *prcRange;

pointer to range rectangle

L_UINT uFlags;

flags

Computes the Discrete Fourier transform of an image or the Inverse Discrete Fourier transform, as specified in the uFlags parameter.

Parameter Description
pBitmap Pointer to the bitmap handle that references the bitmap object of the transformation.
pFTArray Pointer to an FTARRAY structure. The acxData member of the FTARRAY structure is a two-dimensional array that holds the frequency components of the image. Its size must be the same as the image. This array is filled by the function when DFT_DFT flag has been chosen, and it must be sent to the function to construct the image from it when DFT_IDFT flag has been chosen.
prcRange Specifies the frequency range to be computed when DFT_DFT flag is chosen. It specifies the frequency range that will be used in the image construction when DFT_IDFT is chosen. The left value refers to the minimum X harmonic, the right refers to the maximum X harmonic, the top refers to the minimum Y harmonic and the bottom refers to the maximum Y harmonic. The maximum X harmonic equals (Width 1) and the maximum Y harmonic equals (Height 1). The minimum X harmonic equals 0 and the minimum Y harmonic equals 0.
uFlags Flags that indicate the transformation type, operation channel, frequency data type used to reconstruct the image, the clipping type, the used or computed frequencies range, the operation on the specified X harmonics range , and the operation on the specified Y harmonics range. You can use a bitwise OR (|) to specify one flag from each group.
  The following flags represent the transformation type:
  Value Meaning
  DFT_DFT [0x0000001] Convert the image into frequency domain and store the results in the acxData.
  DFT_IDFT [0x0000002] Construct an image using the frequency components from acxData. This option will change the values of acxData.
  The following flags represent the operation channel type:
  Value Meaning
  DFT_BLUE [0x0000010] Use the blue channel.
  DFT_GREEN [0x0000020] Use the green channel.
  DFT_RED [0x0000030] Use the red channel.
  DFT_GRAY [0x0000040] Use the master</b>* 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 DFT_IDFT is set and will be ignored if DFT_DFT is set:
  Value Meaning
  DFT_IDFT_MAG [0x0000100] Construct the image from the frequency magnitude data only.
  DFT_IDFT_PHS [0x0000200] Construct the image from frequency phase data only.
  DFT_IDFT_BOTH [0x0000300] Construct the image from both magnitude and phase data.
  The following flags represent the clipping type. This flag is used only if DFT_IDFT is set and ignored if DFT_DFT is set:
  Value Meaning
  DFT_IDFT_CLIP [0x0001000] Clip the constructed image values so they are between 0 and 255.
  DFT_IDFT_SCL [0x0002000] Scale the constructed image values so they are between 0 and 255.
  The following flags represent which harmonics are used:
  Value Meaning
  DFT_ALL [0x0010000] Use or compute all harmonics. If this flag is used the range rectangle and the range flags will be ignored.
  DFT_RANGE [0x0020000] Use or compute the harmonics specified in the range rectangle.
  The following flags represent the operations on the X Harmonics range:
  Value Meaning
  DFT_INSIDE_X [0x0100000] Use or compute only X harmonics inside the X range and ignore those outside the range.
  DFT_OUTSIDE_X [0x0200000] Use or compute only the X harmonics outside the X range and ignore those inside the range.
  The following flags represent the operations on the Y Harmonics range:
  Value Meaning
  DFT_INSIDE_Y [0x1000000] Use or compute only Y harmonics inside the Y range and ignore those outside the range.
  DFT_OUTSIDE_Y [0x2000000] Use or compute only the Y harmonics outside the Y range and ignore those inside the range.

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 the Discrete Fourier Transform algorithm. Use the L_FFTBitmap to use a Fast Fourier Transform algorithm on a bitmap. Please note however, that this function does not impose the size restrictions (the width and height having to be powers of 2) that the Fast Fourier Transform function, L_FFTBitmap, imposes upon bitmaps.

Before using this function, you need to use the L_AllocFTArray function to allocate a FTARRAY structure large enough to hold Fourier Transform coefficients for pBitmap. When you are finished, you should 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.

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.

*Calculating Master Channel Values

In order to speed up widely used image processing filters in LEADTOOLS, the grayscale value (master channel) of a colored image is calculated using the following formulas:

#define CalcGrayValue(r, g, b) ((L_UCHAR)(((L_UCHAR) (((2 * (L_UINT) (r)) + (5 * (L_UINT) (g)) + (L_UINT) (b) + 4) / 8)))) 
#define CalcGrayValue16(r, g, b) ((L_UINT16) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8)) 
#define CalcGrayValue32(r, g, b) ((L_UINT32) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8)) 

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

Win32, x64, Linux.

See Also

Functions:

L_FFTBitmap, L_FrqFilterBitmap, L_FTDisplayBitmap, L_FrqFilterMaskBitmap, L_AverageFilterBitmap, L_MedianFilterBitmap, 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 DFT function.

L_INT DFTBitmapexample(L_VOID) 
{ 
   L_INT nRet; 
   RECT    rcRange; 
   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(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /*Allocate FT buffer*/ 
   nRet = L_AllocFTArray(&LeadBitmap, &pFTArray, sizeof(FTARRAY), 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   rcRange.left  = 0; 
   rcRange.right = LeadBitmap.Width / 4; 
   rcRange.top = 0; 
   rcRange.bottom = LeadBitmap.Height / 2; 
 
   /* Apply DFT*/ 
   nRet = L_DFTBitmap(&LeadBitmap, pFTArray, &rcRange, DFT_DFT | DFT_GRAY | DFT_RANGE| DFT_INSIDE_X| DFT_OUTSIDE_Y); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* Free FT buffer */ 
   nRet = L_FreeFTArray(pFTArray, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   return SUCCESS; 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help