Anda di halaman 1dari 12

Sintak dari Pembacaan Plat Nomor Kendaraan unit Unit1;

interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, ExtDlgs, TeeProcs, TeEngine, Chart, Series;

type TForm1 = class(TForm) Button1: TButton; PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; TabSheet3: TTabSheet; TabSheet4: TTabSheet; TabSheet5: TTabSheet; TabSheet6: TTabSheet; TabSheet7: TTabSheet; IOriginal: TImage; IMerah: TImage; IHijau: TImage; IBiru: TImage; IGC1: TImage; IGC2: TImage; IGC3: TImage; tgyuguhju: TTabSheet; IGC: TImage;

OpenPictureDialog1: TOpenPictureDialog; Chart1: TChart; Series1: TLineSeries; Chart2: TChart; Chart3: TChart; Series2: TLineSeries; Series3: TLineSeries; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; IHasil: TImage; Label6: TLabel; procedure Button1Click(Sender: TObject); procedure IGC3MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure IGC1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure IGC2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure IOriginalMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end;

type

TRGB32 = packed record B,G,R,A: Byte; end;

TRGB32Array = packed array[0..MaxInt div SizeOf(TRGB32)-1] of TRGB32; PRGB32Array = ^TRGB32Array;

var Form1: TForm1;

implementation

uses Types;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject); var y,x,panjang,lebar : Integer; LineGC31,LineGC32,LineGC33,LineGC34,LineGC35,LineGC36,LineGC37,LineGC38,LineGC 39,LineGC310,LineGC311,LineGC312,LineGC313, LineOriginal,LineMerah,LineBiru,LineHijau,LineGC1,LineGC2,LineGC3,LineIGC: PRG B32Array; jumlahGC1,jumlahGC2,jumlahGC3,K,n:integer; hajarhitamGC3,hajarputihGC3,lebarhitam,itungan,jumlahGC3sebelumnya:integer; ilang,bener:boolean; rerataX:real; kotak:TRect; HasilBMP:TBitmap; begin if (OpenPictureDialog1.Execute)then

begin //membuat Image dengan format 32 bit IOriginal.Picture.LoadFromFile(OpenPictureDialog1.FileName); OpenPictureDialog1.Filter:='BMP files (*.bmp)|*.BMP|';// mendefinisikan file khusus berjenis .BMP

IOriginal.Picture.Bitmap.PixelFormat := pf32bit; IMerah.Picture.Bitmap.PixelFormat IBiru.Picture.Bitmap.PixelFormat IHijau.Picture.Bitmap.PixelFormat IGC1.Picture.Bitmap.PixelFormat IGC2.Picture.Bitmap.PixelFormat IGC3.Picture.Bitmap.PixelFormat IGC.Picture.Bitmap.PixelFormat := pf32bit; := pf32bit; := pf32bit; := pf32bit; := pf32bit; := pf32bit; := pf32bit;

//mendefinisikan gambar panjang dan lebar yang di analisa panjang lebar := IOriginal.Width; := IOriginal.Height;

//mengisi image yang original ke Imerah sampai IGC IMerah.Picture.Assign(IOriginal.Picture); IHijau.Picture.Assign(IOriginal.Picture); IBiru.Picture.Assign(IOriginal.Picture); IGC1.Picture.Assign(IOriginal.Picture); IGC2.Picture.Assign(IOriginal.Picture); IGC3.Picture.Assign(IOriginal.Picture); IGC.Picture.Assign(IOriginal.Picture); //membersihkan semua kondisi clear Series1.Clear; Series2.Clear; Series3.Clear; //menganalisa for y := 0 to lebar - 1 do //menganalisa looping dari Y =0 - Y = lebar -

1 begin LineOriginal := IOriginal.Picture.Bitmap.ScanLine[y];//mengambil ga mbar Iorigigal pada Y LineMerah LineBiru LineHijau := IMerah.Picture.Bitmap.ScanLine[y]; := IBiru.Picture.Bitmap.ScanLine[y]; := IHijau.Picture.Bitmap.ScanLine[y];

LineGC1 LineGC2 LineGC3 LineIGC

:= IGC1.Picture.Bitmap.ScanLine[y]; := IGC2.Picture.Bitmap.ScanLine[y]; := IGC3.Picture.Bitmap.ScanLine[y]; := IGC.Picture.Bitmap.ScanLine[y];

//berapa banyak jumlah warna hitam pada jumlahGC1,jumlahGC2,jumlahGC 3 dimulai dari 0 jumlahGC1:=0; jumlahGC2:=0; jumlahGC3:=0;

//untuk mehilangkan noise hitam dan putih hajarhitamGC3:=0; hajarputihGC3:=0; ilang:=False; //Menganalisa nilai X dari 0 sampai panjang 1 pixel for x := 0 to panjang -1 do begin LineMerah[x].R:=LineOriginal[x].R;//membuat gambar original memjadi warna merah LineMerah[x].G:=0; LineMerah[x].B:=0;

LineHijau[x].R:=0; LineHijau[x].G:=LineOriginal[x].G;//membuat gambar original memjadi

warna Hijau LineHijau[x].B:=0;

LineBiru[x].R:=0; LineBiru[x].G:=0; LineBiru[x].B:=LineOriginal[x].B;//membuat gambar original memjadi w arna Biru // if (LineOriginal[x].R<LineOriginal[x].G)and(LineOriginal[x].G<LineOr iginal[x].B)and (LineOriginal[x].R<50) and (LineOriginal[x].G<200)and (LineOriginal[ x].B<200)or(LineOriginal[x].R<90)and (LineOriginal[x].G - LineOriginal[x].R<35) and (LineOriginal[x].B LineOriginal[x].G<35) then begin //jika memenuhi syarat (if) akan di hitamkan LineIGC[x].R:=0; LineIGC[x].G:=0; LineIGC[x].B:=0; end else //jika tidak memenuhi syarat (if) begin LineIGC[x].R:=255; LineIGC[x].G:=255; LineIGC[x].B:=255; end; //IGC1 if LineIGC[x].R>180 then//jika pada Line begin LineGC1[x].R:=255; LineGC1[x].G:=255; LineGC1[x].B:=255; end;

if LineIGC[x].R<=180 then begin LineGC1[x].R:=0; LineGC1[x].G:=0; LineGC1[x].B:=0; end; //mengetahui grafik if x>0 then if (LineGC1[x].R=0)and (LineGC1[x-1].R=255)then inc(jumlahGC1); //IGC2 if LineIGC[x].R>125 then begin LineGC2[x].R:=255; LineGC2[x].G:=255; LineGC2[x].B:=255; end; if LineIGC[x].R<=125 then begin LineGC2[x].R:=0; LineGC2[x].G:=0; LineGC2[x].B:=0; end;

if x>0 then if (LineGC2[x].R=0) and(LineGC2[x-1].R=255) then inc(jumlahGC2);

//IGC3 if (LineIGC[x].R>125) and (LineIGC[x].G>125) and (LineIGC[x].B>125) then

begin //jika memenuhi syarat maka di buat putih LineGC3[x].R:=255; LineGC3[x].G:=255; LineGC3[x].B:=255; //syarat tambahan menghilangkan warna hitam di sebelah Kiri if abs(x-hajarhitamGC3)<500 then begin for k:=0 to hajarhitamGC3 do begin LineGC3[K].R:=255; LineGC3[K].G:=255; LineGC3[K].B:=255; end; end; //menghilangkan warna hitam yang ditengah if hajarhitamGC3>50 then begin for k:=x-hajarhitamGC3 to x-1 do begin LineGC3[K].R:=255; LineGC3[K].G:=255; LineGC3[K].B:=255; end; end;

//variabel hajar hitam dan putih hajarputihGC3:=0; hajarhitamGC3:=0; //hajartitikGC3:=0; end;

if (LineIGC[x].R<=50) and (LineIGC[x].G<=50) and (LineIGC[x].B<=50) then begin //jika syarat terpenuhi maka di buat hitam LineGC3[x].R:=0; LineGC3[x].G:=0; LineGC3[x].B:=0; inc(hajarhitamGC3);

if abs(x-panjang)<2 then begin for k:=panjang-hajarhitamGC3 to panjang-2 do begin LineGC3[K].R:=255; LineGC3[K].G:=255; LineGC3[K].B:=255; end; end; end; if x>0 then if (LineGC3[x].R=0) and (LineGC3[x-1].R=255) then inc(jumlahGC3); if hajarhitamGC3>200 then jumlahGC3:=0 ;

if jumlahGC3>30 then begin for k:=0 to panjang-1 do begin LineGC3[K].R:=255;

LineGC3[K].G:=255; LineGC3[K].B:=255; end; end;

for k:=0 to panjang-3 do begin if (LineGC3[K].R=255) and (LineGC3[K+1].R=0) and (LineGC3[K+2].R= 255) then begin LineGC3[K+1].R:=255; LineGC3[K+1].G:=255; LineGC3[K+1].B:=255; end; end;

end; if (jumlahGC3>20) then jumlahGC3:=0; if (jumlahGC3<10) then jumlahGC3:=0; Series1.AddXY(y,jumlahGC1); Series2.AddXY(y,jumlahGC2); end;

y:=0; n:=0; rerataX:=0; ////////////////////////////////////// repeat begin LineGC3 LineGC31 := IGC3.Picture.Bitmap.ScanLine[y]; := IGC3.Picture.Bitmap.ScanLine[y+1];

LineGC32 LineGC33 LineGC34 LineGC35 LineGC36 LineGC37 LineGC38 LineGC39 LineGC310 LineGC311 LineGC312 LineGC313 bener:=false; itungan:=0;

:= IGC3.Picture.Bitmap.ScanLine[y+2]; := IGC3.Picture.Bitmap.ScanLine[y+3]; := IGC3.Picture.Bitmap.ScanLine[y+4]; := IGC3.Picture.Bitmap.ScanLine[y+5]; := IGC3.Picture.Bitmap.ScanLine[y+6]; := IGC3.Picture.Bitmap.ScanLine[y+7]; := IGC3.Picture.Bitmap.ScanLine[y+8]; := IGC3.Picture.Bitmap.ScanLine[y+9]; := IGC3.Picture.Bitmap.ScanLine[y+10]; := IGC3.Picture.Bitmap.ScanLine[y+11]; := IGC3.Picture.Bitmap.ScanLine[y+12]; := IGC3.Picture.Bitmap.ScanLine[y+13];

for x := 0 to panjang-1 do if not bener then begin if (x>=150) and (x<290)and(LineGC3[x].R=255) and (LineGC31[x].R= 0) and (LineGC32[x].R=255)then begin LineGC31[x].R:=255; LineGC31[x].G:=255; LineGC31[x].B:=255; end; if (x<150) or (x>290)then begin LineGC31[x].R:=255; LineGC32[x].R:=255;

LineGC33[x].R:=255; LineGC34[x].R:=255; LineGC35[x].R:=255; LineGC36[x].R:=255; LineGC37[x].R:=255; LineGC38[x].R:=255; LineGC39[x].R:=255; LineGC310[x].R:=255; LineGC311[x].R:=255; LineGC312[x].R:=255; /////////////////// LineGC31[x].G:=255; LineGC32[x].G:=255; LineGC33[x].G:=255; LineGC34[x].G:=255; LineGC35[x].G:=255; &n