virtual L_INT LBitmap::DFT (pFTArray, prcRange, uFlags)
Computes the Discrete Fourier transform of an image or the Inverse Discrete Fourier transform as specified in the uFlags parameter.
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.
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.
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. Use a bitwise OR ( | ) to specify one flag from each group.
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. |
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. |
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. |
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. |
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. |
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. |
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. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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, call the LBitmap::AllocFTArray function to allocate a FTARRAY structure large enough to hold Fourier Transform coefficients for pBitmap. When finished, free the allocated array by calling the LBitmap::FreeFTArray function.
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 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.
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))
Win32, x64.
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;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document