UserFilter example for Delphi
{In this example the high pass filter will be applied using user defined matrix}
procedure TForm1.Button1Click(Sender: TObject);
var
{ Allocate the user filter matrix. We need a (3x3) matrix with 9 elements. }
ufltMatrix: Array [0..8] of L_INT;
i: L_INT;
j: L_INT;
pt: TPoint;
begin
{ 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 to 2 do
begin
for j:= 0 to 2 do
begin
if ( (j = 1) Or (i = 1) ) Then
begin
if( (j = 1) And (i = 1) ) then
begin
ufltMatrix[i * 3 + j]:= 5;
end
else
begin
ufltMatrix[i * 3 + j]:= -1;
end;
end
else
begin
ufltMatrix[i * 3 + j]:= 0;
end;
end;
end;
pt.x:= 1;
pt.y:= 1;
{ Apply the high pass custom filter }
LEADImage1.UserFilter(3, 3, pt, 1, 0, @ufltMatrix, UD_SUM);
end;