Declaration
procedure filter2D(dst: TIEVisionImage; kernel: TIEVisionImage; anchor: TIEVisionPoint); overload; safecall;
procedure filter2D(kernel: TIEVisionImage; anchor: TIEVisionPoint); overload; safecall;
procedure filter2D(kernel: PSingle; kernelWidth: int32_t; kernelHeight: int32_t; anchor: TIEVisionPoint); overload; safecall;
Description
Convolve an image with the kernel.
First overload places the result into destination object.
Second and third overloads update the current image.
Parameter | Description |
dst | Container for the destination image |
kernel | Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix. To apply different kernels to different channels, split the image into separate color planes using splitPlanes and process them individually |
anchor | Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value (-1, -1) means that the anchor is at the kernel center |
Note: You can use
assignIEVisionImage to reflect this methods changes in the associated bitmap
| Demos\ImageEditing\EveryMethod\EveryMethod.dpr |
// Examples using a 3x3 sharpen kernel
// First overload (with source->destination image)
const
sharpenKernel: array [0..2] of array [0..2] of single = ((-1, -1, -1), (-1, 8, -1), (-1, -1, -1));
var
tempBmp: TIEBitmap;
k: TIEVisionImage;
i, j: integer;
l: PSingleArray;
begin
// convert the kernel to TIEVisionImage
k := IEVisionLib().createImage(3, 3, ievFLOAT32, 1);
for i := 0 to 2 do
begin
l := k.getScanline(i);
for j := 0 to 2 do
l[j] := sharpenKernel[i, j];
end;
// perform filter2D from temporary image to ImageEnView1
ImageEnView1.IO.loadFromFile('input.jpg');
tempBmp := TIEBitmap.Create();
tempBmp.Assign( ImageEnView1.IEBitmap );
tempBmp.GetIEVisionImage().filter2D(ImageEnView1.IEBitmap.GetIEVisionImage(), k, IEVisionPoint(1, 1));
ImageEnView1.update();
tempBmp.Free;
end;
// Second overload (in-place operation)
const
sharpenKernel: array [0..2] of array [0..2] of single = ((-1, -1, -1), (-1, 8, -1), (-1, -1, -1));
var
k: TIEVisionImage;
i, j: integer;
l: PSingleArray;
begin
// convert the kernel to TIEVisionImage
k := IEVisionLib().createImage(3, 3, ievFLOAT32, 1);
for i := 0 to 2 do
begin
l := k.getScanline(i);
for j := 0 to 2 do
l[j] := sharpenKernel[i, j];
end;
// perform filter2D in place operation
ImageEnView1.IO.LoadFromFile('input.jpg');
ImageEnView1.IEBitmap.GetIEVisionImage().filter2D(k, IEVisionPoint(1, 1));
ImageEnView1.Update();
end;
// Third overload (using Delphi matrix and in-place operation)
const
sharpenKernel: array [0..2] of array [0..2] of single = ((-1, -1, -1), (-1, 8, -1), (-1, -1, -1));
begin
ImageEnView1.IO.LoadFromFile('input.jpg');
ImageEnView1.IEBitmap.GetIEVisionImage().filter2D(@sharpenKernel[0, 0], 3, 3, IEVisionPoint(1, 1));
ImageEnView1.Update();
end;