FreqDIBEnhance

#include "BIFILTER.H"

 

HANDLE CALLBACK FreqDIBEnhance( HANDLE hSrcDIB,
WORD      nCutoff,
float           fAttenuate,
BOOL       bFFTMethod,
BOOL       bShowDialog)

Description

It is an enhanced highpass filter function which preserves low frequency components. It uses Fast Fourier Transform (FFT) algorithm to obtain the Fourier spectrum. In the frequency domain, a filter function attenuates the low frequency components. After that, the inverse FFT algorithm is applied to go back to the spatial domain. Then part of the original image is added back to the highpass result, which restores partially the low-frequency components lost in the highpass filtering operation. It works with 4, 8 or 24 bits/pixel.. In case of 4 or 8 bits/pixel, the source DIB must contain grayscale image 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 a power of two, zero padding is used.

Examples

macska                                                  macskaenhance

The original 180 x 210 size image and the FFT-enhanced image with Cutoff = 100 and Attenuate = 1.2 parameter values.

Parameters

HANDLE

hSrcDIB

Source DIB

WORD

nCutoff

Cutoff frequency. See the description and examples above for further information and a possible value.

float

fAttenuate

Controls the low-frequency component. See the description and examples above for further information and a possible value.

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 does not pass any 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 the zero pass frequency is  sqrt(2) * 128 / 2 = 90. Of course this is true only if fAttenuate = 1.

fAttenuate
If fAttenuate = 1, then no part of the original image is added back, so this function is the same as the FreqDIBHighpass() function. If fAttenuate > 1, then part of the original image is added back to preserve low frequency components. Recommended value is 1.1.

Requirements

Header :     Declared in BIFilter.h; include BIFilter.h.

Library :    Use BIFilter.lib.

DLLs :       BIFilter.dll.