Simpan program dengan cara save all. Keluar dari program klik button Exit.

row:array[0..8] of pbytearray; col:pbytearray; x,y:smallint; i,j,k,p:smallint; image:tbitmap; sum,jum:longint; begin p:=-120; image:=Tbitmap.Create; image.AssignImage1.Picture.Bitmap; for y:=1 to Image1.Height-2 do begin for i:=-1 to 1 do row[i+1]:=image.ScanLine[y+i]; col:=Image1.Picture.Bitmap.ScanLine[y]; x:=3; repeat sum:=0; for i:=-1 to 1 do for j:=-1 to 1 do sum:=sum+sobel[0,i+1,j+1]row[i+1,x+j3]; jum:=0; for i:=-1 to 1 do for j:=-1 to 1 do jum:=jum+sobel[1,i+1,j+1]row[i+1,x+j3]; sum:=sum+jum+p; if sum255 then sum:=255; if sum0 then sum:=0; for k:=0 to 2 do col[x+k]:=sum; incx,3; until x=3Image1.Width-4; end; Image2.picture.bitmap:=Image1.Picture.Bitmap; image.free; end; procedure TFormSobel.btExitClickSender: TObject; begin FormSobel.Close; end; end. unit UnitImageProses; interface uses WINPROCS, Graphics, ExtCtrls, ComCtrls, Variants; type TFreqHist = array [0..255] of longint; TMatrixFilter = array [1..16,1..16] of real; function RgbToGray Clr:TColor : byte; function ImgGetGray var Image:TImage; x,y:integer : byte; procedure ImgConvertToGrayscale var Image1:TImage; var ProgressBar1: TProgressBar; implementation const PercentR = 0.299; PercentG = 0.587; PercentB = 0.114; function ByteRange r:double : byte; begin if r0 then ByteRange:=0 else if r255 then ByteRange:=255 else ByteRange:=Roundr; end; function RgbToGray Clr:TColor : byte; var r,g,b:byte; begin r := GetRValueClr; g := GetGValueClr; b := GetBValueClr; RgbToGray := ByteRange rPercentR + gPercentG + bPercentB; end; function ImgGetGray var Image:TImage; x,y:integer : byte; begin Result := RgbToGray Image.Canvas.Pixels[x,y]; end; procedure ImgConvertToGrayscale var Image1:TImage; var ProgressBar1: TProgressBar; var x,y:integer; ClrGray:byte; begin ProgressBar1.Max := Image1.Width-1; ProgressBar1.Position := 0; for x:=0 to Image1.Width-1 do begin for y:=0 to Image1.Height-1 do begin ClrGray := ImgGetGray Image1,x,y; Image1.Canvas.Pixels[x,y] := RGB ClrGray,ClrGray,ClrGray; end; Image1.Repaint; ProgressBar1.Position := x; end; end; end.