LBitmap::DFT

#include "ltwrappr.h"

virtual L_INT LBitmap::DFT (pFTArray, prcRange, uFlags)

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

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 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 LBitmap::FFT 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, LBitmap::FFT, imposes upon bitmaps.

Before using this function, you need to use the LBitmap::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 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.

Platforms

Win32, x64.

See Also

Functions:

LBitmap::Fragment, LBitmap::HighPassFilter, LBitmap::UnsharpMask, LBitmap::AverageFilter, LBitmap::MedianFilter, LBitmap::AddNoise, LBitmap::IntensityDetect, LBitmap::SpatialFilter, LBitmap::BinaryFilter, LBitmap::MaxFilter, LBitmap::MinFilter, LBitmap::AddShadow, LBitmap::AllocFTArray, LBitmap::ChangeHueSatInt, LBitmap::ColorReplace, LBitmap::ColorThreshold, LBitmap::DirectionEdgeStatistical, LBitmap::FFT, LBitmap::FreeFTArray, LBitmap::FrqFilter, LBitmap::FrqFilterMask, LBitmap::FTDisplay, LBitmap::GetStatisticsInfo, LBitmap::GetFeretsDiameter, LBitmap::GetObjectInfo, LBitmap::GetRgnContourPoints, LBitmap::GetRgnPerimeterLength, LBitmap::MathFunction, LBitmap::RevEffect, LBitmap::Segment, LBitmap::SubtractBackground, LBitmap::UserFilter, LBitmap::DirectionEdgeStatistical2

Topics:

Raster Image Functions: Fourier Transform Functions

 

Removing Noise

 

Raster Image Functions: Removing Noise

Example

L_INT LBitmap__DFTExample(LBitmap *pLeadBitmap) 
{
   L_INT nRet;
   /* This example loads a bitmap and applies DFT function. */
   RECT    rcRange; 
   pFTARRAY  pFTArray; 
   /*Allocate FT buffer*/
   nRet =pLeadBitmap->AllocFTArray (&pFTArray, sizeof(FTARRAY));
   if(nRet !=SUCCESS)
      return nRet;
   rcRange.left  = 0; 
   rcRange.right = pLeadBitmap->GetWidth () / 4; 
   rcRange.top = 0; 
   rcRange.bottom = pLeadBitmap->GetHeight () / 2; 
   /* Apply DFT*/
   nRet =pLeadBitmap->DFT(pFTArray, &rcRange, DFT_DFT | DFT_GRAY |    
                          DFT_RANGE| DFT_INSIDE_X| DFT_OUTSIDE_Y);
   if(nRet !=SUCCESS)
      return nRet;
   /*
   : 
   : 
    Free FT buffer */
   nRet =LBitmap::FreeFTArray (pFTArray);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}