UserFilter example for C++ Builder
/*In this example the high pass filter will be applied using user defined matrix*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
/* Allocate the user filter matrix. We need a (3x3) matrix with 9 elements. */
L_INT ufltMatrix[3*3];
L_INT i, j;
TPoint pt;
/* Load a bitmap at its own bits per pixel */
LEADImage1->Load("image1.cmp", 0, 1, 1 );
/* Initialize the array with factor used to apply the high pass filter */
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
if(j == 1 || i == 1)
{
if(j == 1 && i == 1)
ufltMatrix[i * 3 + j] = 5;
else
ufltMatrix[i * 3 + j] = -1;
}
else
ufltMatrix[i * 3 + j] = 0;
}
}
pt.x = 1;
pt.y = 1;
/* Apply the high pass custom filter */
LEADImage1->UserFilter(3, 3, pt, 1, 0, ufltMatrix, UD_SUM);
}