Contra-Harmonic Mean Filter

#include "BIFILTER.H"


HANDLE CALLBACK FilterContraHarmonicMean(               HDIB        hDIB,
int           N,
int           P,
int           iShowProgress,
HWND  hParent)


This function will filter the image by the nonlinear contra-harmonic mean method. This function works for only monochrome, 8 bit per bixel and 24 bit per pixel images. The contra-harmonic mean filter is member of a set of nonlinear mean filters which are better at removing Gaussian type noise and preserving edge features than the arithmetic mean filter. The contra-harmonic filter is very good at removing positive outliers for negative values of P and negative outliers for positive values of P. The definiton of contra-harmonic filter is :

where the coordinate (x+i, y+j ) is defined over the image A and the coordinate (i j) is defined over the N x N size square mask.


Description: Gauss                                    Description: contra

The original 256 x 256 pixel image corrupted by additive Gauss noise and the contra-harmonic mean filtered image using a 5 x 5 pixel square mask and P = -2.




Handle of the DIB to filter.



This parameter specifies the size of the square mask. N cannot be less than 1. See the description and examples above for further information and a possible value.



This parameter specifies the value P in the equation above. See the description and examples above for further information and a possible value.



This parameter specifies the displaying of the progressbar and the preview dialog.

Available values:

DISPLAY_NONE (0)      -     The progressbar and the preview dialog will not display before filtering.

DISPLAY_PROGRESS (1) -The progressbar will display during filtering procedure.

DISPLAY_DIALOG (2) -     The preview dialog will display before filtering. This dialog shows the part of the image before and after filtering.

DISPLAY_BOTH (3)      -     The progressbar and the preview dialog will display.

IMPORTANT: The preview dialog will only display, if there is BiDlgs.dll installed.



Handler of the parent window.

Return values

The handle of the new filtered DIB or NULL if an error occurred.

Programming notes

The function will not free the input DIB.


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

Library :    Use BIFilter.lib.

DLLs :       BIFilter.dll , BIDlgs32.dl.