#include "BIFILTER.H"
HANDLE CALLBACK FreqDIBLowpass( HANDLE hSrcDIB,
WORD nCutoff,
WORD nType,
BOOL bFFTMethod,
BOOL bShowDialog)
Description
This function attenuates the high-frequency components. It uses Fast Fourier Transform (FFT) algorithm to obtain the Fourier spectrum. In the frequency domain, a filter function attenuates the high-frequency components. After that, the inverse FFT algorithm is applied to obtain the result DIB. It works with 4, 8 or 24 bits/pixel. In case of 4 or 8 bits/pixel, the source DIB must contain grayscale images and the palette values in the source DIB must be monotone increasing. It makes no sense to use this function in case of 1 bits/pixel. If the source DIB size is not power of two, zero padding is used.
Examples
The original 180 x 210 size image and the FFT-Lowpassed filtered image with Cutoff = 40 and ideal filter.
Parameters
HANDLE |
hSrcDIB |
Source DIB |
WORD |
nCutoff |
Cutoff frequency. See the description and examples above for further information and a possible value. |
WORD |
nType |
The filter function in the frequency domain. 1: FILTER_IDEAL 2: FILTER_BUTTERWORTH |
BOOL |
bFFTMethod |
There are two ways realized to process the power spectra of an image. One uses trigonometrical sinus and cosinus functions and the other one uses square root functions. There can be different between the two ways only at the processing time. Available values: TRUE (1) - The power spectra will be processed by sinus and cosinus functions. FALSE (0) - The power spectra will be processed by square root functions. |
BOOL |
bShowDialog |
This parameter specifies that is the preview dialog to be displayed or not. |
Return values
Handle of the newly created DIB on success or NULL on failure.
Programming notes
Cutoff frequency
This function passes all frequency components if the ‘nCutoff’ parameter is greater than the radius of the image. For example, if the size of the source image is 128 x 128, then all of the pass frequencies is sqrt(2) * 128 / 2 = 90. Of course this is true only if nType = FILTER_IDEAL.
Ideal lowpass filter (‘nType = FILTER_IDEAL)
The name ideal filter indicates that all frequencies inside a circle of radius ‘nCutoff’ are passed with no attenuation, whereas all frequencies outside this circle are completely attenuated.
Butterworth lowpass filter (‘nType’ = FILTER_BUTTERWORTH)
H(u, v) = 1 / ( 1 + ( D(u, v) / D0 ) ^ 2) )
H(u, v): Filter function, ‘u’ and ‘v’ is the frequency variable.
D(u, v): Distance from the origin of the frequency plane: sqrt( u*u + v*v )
D0: Cutoff frequency (nCutoff)
Requirements
Header : Declared in BIFilter.h; include BIFilter.h.
Library : Use BIFilter.lib.
DLLs : BIFilter.dll.