unit UnitUtama; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtDlgs, Menus

, StdCtrls, ComCtrls, Clipbrd, ExtCtrls, TeeProcs, TeEngine, Chart, Series, CPort; type TFormUtama = class(TForm) PanelAtas: TPanel; ButtonAmbilCitra: TButton; StatusBar: TStatusBar; OpenPictureDialog: TOpenPictureDialog; ButtonSegmentasi: TButton; ButtonDeteksiTepi: TButton; ButtonHitam: TButton; ButtonPutih: TButton; ButtonReset: TButton; ButtonSave: TButton; ButtonClose: TButton; Shape1: TShape; Shape2: TShape; Memo1: TMemo; SaveDialog1: TSaveDialog; SavePictureDialog1: TSavePictureDialog; ComPort1: TComPort; Edit1: TEdit;

Button1: TButton; Edit2: TEdit; Button2: TButton; ButtonPrint: TButton; Label1: TLabel; Label3: TLabel; Label2: TLabel; Label4: TLabel; procedure ButtonAmbilCitraClick(Sender: TObject); procedure Segmentasi; procedure DeteksiTepi; procedure ButtonSegmentasiClick(Sender: TObject); procedure ButtonDeteksiTepiClick(Sender: TObject); procedure ButtonCloseClick(Sender: TObject); procedure ButtonSaveClick(Sender: TObject); procedure ButtonHitamClick(Sender: TObject); procedure ButtonPutihClick(Sender: TObject); procedure ComPort1RxChar(Sender: TObject; Count: Integer); procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Edit1Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure ButtonPrintClick(Sender: TObject); private { Private declarations } public

Width. var FormHasil: TFormCitra.Picture.Picture. case (FormCitra. {$R *.Height.Image.yy]. var fc: string.Image.Image.Picture.Picture.Top. FormCitra).Execute) then begin if (FormCitra = nil) then Application. FormHasil.Picture.Canvas.Width) + 'x' + IntToStr(FormCitra. end.Bitmap.Image.dfm} procedure TFormUtama. urutan : integer.ClientWidth :=FormCitra. begin for xx:=1 to FormCitra. begin if (OpenPictureDialog. C .Picture. G. for yy:=1 to FormCitra. FormHasil.Width do FormCitra. FormHasil.Image. yy.ClientHeight := FormCitra. jj. FormCitra. StatusBar.Image.ClientHeight := FormHasil.Left.Image.Picture.FileName + ' (' + IntToStr(FormCitra. ii.ClientHeight :=FormCitra. FormHasil.Top := FormCitra.{ Public declarations } end.ClientHeight := FormHasil. B.Image. procedure TFormUtama.SimpleText := OpenPictureDialog. end. xx.Image.Image.Height do FormCitra. implementation uses UnitCitra. FormCitra.Height.Height) + '.ClientWidth := FormHasil.Picture.Pixels[xx.Image. R. pf24bit : fc := 'true color'.PixelFormat) of begin C:=FormCitra.CreateForm(TFormCitra.ButtonAmbilCitraClick(Sender: TObject). pf8bit : fc := 'keabuan'. var FormUtama: TFormUtama. R:= C mod $100.Image.Picture := FormCitra. G:= (C div $100)mod $100. terimaserial: string.CreateForm(TFormCitra. ' + fc + ')'. . klm : Integer.Picture.Left := FormCitra.Image. FormHasil.FileName). FormHasil). FormHasil.Image.Picture.Image.Segmentasi.Picture.Height.Width. if (FormHasil = nil) then Application. pf1bit : fc := 'biner'.Picture. FormHasil.Caption := 'Citra Hasil'.Picture. brs.LoadFromFile( OpenPictureDialog. end.Picture.Bitmap.Height.

Bitmap. end.Image.Image.Canvas.Pixels[xx.B:= C div $10000.Pixels [xx+ii.Image.Canvas.Canvas.Bitmap.Picture.Bitmap.Picture.Picture.Picture.yy+jj] then FormHasil.Canvas. procedure TFormUtama.Image. FormHasil.Image.Width do for yy:=0 to FormHasil.yy]:=B*$1 exit. Pixels [xx.yy]:=B*$1 Segmentasi.yy]:=clBlack.Image.Picture.Bitmap. end. end.Picture.Image.Picture.ButtonDeteksiTepiClick(Sender: TObject).Picture.Canvas.Bitmap. end.Pixels[xx.yy]:=clWh Segmentasi. Begin for xx:=0 to FormHasil. end. ite. end. exit.Image. 0000+G*$100+R. FormCitra. begin if (FormCitra = nil) then begin ShowMessage('Ambil dulu citra yang akan diolah'). end. begin if (FormCitra = nil) then begin ShowMessage('Ambil dulu citra yang akan diolah').Height do begin C:= FormCitra. begin if (FormCitra = nil) then begin ShowMessage('Ambil dulu citra yang akan diolah').Pixels[xx. DeteksiTepi. .ButtonHitamClick(Sender: TObject).Bitmap. exit.DeteksiTepi. end. procedure TFormUtama.Canvas. procedure TFormUtama.Pixels[xx. end. procedure TFormUtama.ButtonSegmentasiClick(Sender: TObject). for ii:=-1 to +1 do for jj:=-1 to +1 do if C<>FormCitra. 0000+G*$100+R. B:= ((b*4) div 256) *(255 div (3)).yy]. R:= ((r*4) div 256) *(255 div (3)).Bitmap. G:= ((g*4) div 256) *(255 div (3)).Bitmap. FormHasil.

terimaserial := ''.klm]=Sha if (FormCitra = nil) then pe2.Canvas. end.Picture.Image.Pixels[brs.Picture. pe1. Name).Picture.Bitmap.Pixels[brs.Image.ButtonCloseClick(Sender: TObject).Brush.klm]:=clB exit.ButtonSaveClick(Sender: TObject).for brs:=0 to FormCitra.Canvas.Picture.Image.ReadStr(dataterima. end. end.Picture.Bitmap. FormCitra.height do begin if end.SaveToFile(SavePictureDialog1. . end.Width do for klm:=0 to FormCitra. begin Comport1.Picture. end.Bitmap. exit.klm]=Sha terimaserial := terimaserial+dataterima. lack.Pixels[brs.Picture. procedure TFormUtama.Image.ButtonPutihClick(Sender: TObject).Bitmap. begin if (FormCitra = nil) then begin ShowMessage('Ambil dulu citra yang akan diolah').Picture. Var dataterima: String.Bitmap.Execute then FormHasil.Color then if pos(#13+#10. end.Canvas.Image. if SavePictureDialog1.klm]:=cl edit1.Bitmap. for brs:=0 to FormCitra.ComPort1RxChar(Sender: TObject.Image.Image.Canvas.Image.Image.Width do for klm:=0 to FormCitra.terimaserial)> 0 then begin FormHasil. begin FormCitra.count).Bitmap. White.height do begin if end.Picture. procedure TFormUtama.Color then begin ShowMessage('Ambil dulu citra yang akan diolah').File procedure TFormUtama.Bitmap. FormHasil. begin Close. Count: Integer).Text:= terimaserial. procedure TFormUtama.Brush.Pixels[brs.

yy]=clblac k then ADAHITAM:=TRUE.warnaawal.Caption:= Timetostr(now).FormCreate(Sender: TObject).Caption:=timetostr(now).text + #13).Pixels[ 00. comport1.Button1Click(Sender: TObject). ADAHITAM:BOOLEAN. putih:=0. Label1.Pixels[xx.Strings[0]+'00'+ #13). end.Image.Strings[urutan]+'00'+ #13).Picture.Width-1 do begin .yy].Width-1 do begin if FormHasil.Image. begin Comport1. YY:=0.hitam: integer.putih. urutan := 0. warnaawal:=FormHasil. procedure TFormUtama.Canvas.Edit1Change(Sender: TObject). end. begin memo1.Picture.Picture.Text) > 0 then begin urutan := urutan+1. IF ADAHITAM THEN BEGIN hitam:=0.yy].WriteStr(memo1.Canvas. END. procedure TFormUtama. REPEAT hitam:=0.Button2Click(Sender: TObject). end. end.Image.WriteStr(edit2.Bitmap.ButtonPrintClick(Sender: TObject). edit1. putih:=0.Bitmap. procedure TFormUtama. FormUtama.yy. var xx. procedure TFormUtama.end. end.Picture.Image. end. ADAHITAM:=FALSE.Canvas. begin terimaserial :=''. begin Comport1.Text:=''. for xx:=0 to FormHasil. for xx:=0 to FormHasil.Lines.WriteStr(Memo1. warnaawal:=FormHasil. procedure TFormUtama.Bitmap.Bitmap.Image.Pixels[ 00.Lines.Bitmap.Picture. begin if pos('-OK'.

Add('C1').Lines. end.Picture.Canvas. if warnaawal<>clwhite then begin memo1.Lines.Append('C1'). memo1.Bitmap.Picture.Append('A'+inttostr(putih)). putih:=0. memo1.Height-1 end. end else begin if warnaawal<>clwhite then begin memo1. FormHasil.Image. hitam:=hitam+1. else memo1. warnaawal:=clwhite. memo1. . end.Append('A'+inttostr(putih)).yy]=clblac end k then begin if warnaawal<>clBlack then memo1.Lines.Lines.Append('F10') .Lines. hitam:=0. END ELSE BEGIN MEMO1.Lines.Lines.Append('F10') . UNTIL YY=FormHasil.Pixels[xx. end.if memo1.Append('A'+inttostr(hitam)) . memo1. YY:=YY+1.Append('A'+inttostr(hitam)) . warnaawal:=clBlack.Lines.Lines.Append('E10') . putih:=putih+1.Append('E10') . END.Bitmap.Lines.Image. end.