ColorConvolution

#include "BIImage.h"

 

HANDLE CALLBACK ColorConvolution(
HANDLE       hDIB1,
BOOL             bUndoMode,
BOOL             bPsychovisual,
short                nFilterType,
short                nSize,
LPTSTR          lpFileName,
short FAR       *lpFilter,
LPINT             lpnErrorFlag,
int                    iShowProgress,
HWND           hParent)

Description

Execute the convolution filtering using the convolution kernel with prescribed size, coefficients and normalising divider on  color (8 bits/pixel) device independent bitmap.

The pixel value P'(i,j) after the convolution: sum of the close neighbouring pixel values (multiplied with the proper element of convolution kernel) and divide with the normalising divider.

The luminence is weighted (RED*GREEN*BLUE)/3 if bPsychovisual is set to FASLE or the following scheme is used (8*RED+15*GREEN+3*BLUE)/26.

 

Type of filter to be used:

USER                                     The coefficients are given by the user (See: lpFilter)

FROMFILE                          The coefficients are given by a file (See: lpFileName)

SMOOTH                              Noise filter (all the coeffs. are the same: 1)

WEIGHTEDSMOOTH       Weighted noise filter e.g. if nSize=3, the filter is:

                                                        1   2   1

                                                        2   4   2

                                                        1   2   1

LAPLACE                            Laplace filter (digital grad., e.g. if nSize=3, the filter is:

                                                        0   -1    0

                                                        -1   5   -1

                                                        0   -1    0

WEIGHTEDLAPLACE      Weighted Laplace filter, e.g. if nSize=3, the filter is:

                                                        -1   -1   -1

                                                        -1    9   -1

                                                        -1   -1   -1

Additional Information

This example shows how to use the dll when loading statically including the header file. Otherwise if the dll is loaded dynamically, for further information read the “About the difference of static and dynamic library loading” section of the manual.

Parameters

HANDLE

hDIB1

Handle to the 8 bits/pixel DIB to be convolved

BOOL

bUndoMode

If TRUE a new DIB will be created, otherwise the old one will be modified..

BOOL

bPsychovisual

Determines the computation of pixel luminence.

short

nFilterType

Type of filter to be used..

short

nSize

Size of the convolution filter (3, 5, or 7) in the case of filter type USER and SMOOTH 7

LPSTR

lpFileName

The name of  file containing the nSize*nSize pieces of integer coefficients and after them an integer normalising weight if the filter type is equal to FROMFILE. The sum of positive and negative coefficients must be in a range of{-127...+128}.

short FAR

*lpFilter

Pointer to an array containing the nSize*nSize pieces of integer coefficients and after them an integer normalising weight if the filter type is equal to USER. The sum of positive and negative coefficients must be in a range of{-127...+128}.

LPINT

lpnErrorFlag

Pointer to an error code. If IOK there is no error.

int

iShowProgress

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.

HWND

hParent

Handler of the parent window.

Return Value

Handle to an output DIB or NULL on error.

Programming notes

This functions does not delete the original DIB. Memory intensive operation, make sure you have enough memory.

Requirements

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

Library :    Use BIImage.lib.

DLLs :       BIimage.dll.

Code example

None at present.