Var
c1,c2,x,p,q,i,j : Integer;
b1,b2 : TBitmap;
r : TRect;
begin
b1 := TBitmap.create;
b2 := TBitmap.create;
r := rect (0,0,image1.width, image1.height);
b1.width := image1.width;
b1.Height := image1.Height;
b2.width := image1.width;
b2.Height := image1.Height;
b1.Canvas.Draw(0,0,image1.Picture.Graphic);
b2.Canvas.Draw(0,0,image2.Picture.Graphic);
Image3.Width := image1.Width;
image3.Height := Image1.Height;
For i:=0
to image1.Height - 1
do
for j:=0
to image1.Width - 1
do begin
p := b1.Canvas.Pixels[j,i];
q := b2.Canvas.Pixels[j,i];
c1 := (GetRValue(p) + GetGValue(p) + GetBValue(p))
div 3;
c2 := (GetRValue(q) + GetGValue(q) + GetBValue(q))
div 3;
c1 := abs(c1 - c2);
x :=
rgb ( c1,c1,c1);
image3.Canvas.Pixels[j,i] := X;
End;
b1.free;
b2.free;
end;