{
This function performs a 2D convolution on an image.
It can be used for a very wide range of image processing operations
such as image smoothing, anti-aliasing, edge detection,
detail enhancment, etc. It is very fast.
}
uses Graphics, Windows;
type TRGBTripleArray = array[0..10000] of TRGBTriple;
PRGBTripleArray = ^TRGBTripleArray;
T3x3FloatArray = array[0..2] of array[0..2] of Extended;
implementation
function Convolve(ABitmap: TBitmap; AMask: T3x3FloatArray;
ABias: Integer): TBitmap; var LRow1, LRow2, LRow3, LRowOut: PRGBTripleArray;
LRow, LCol: integer;
LNewBlue, LNewGreen, LNewRed: Extended;
LCoef: Extended; begin LCoef := 0; for LRow := 0 to 2 do
for LCol := 0 to 2 do LCoef := LCoef + AMask[LCol, LRow]; if LCoef = 0 then LCoef := 1;