Anda di halaman 1dari 1

procedure TForm1.

Histogram;
var piksel : PByteArray;
Gray, TotalPiksel, i, brs, kol : integer;
r,g,b: Real;
begin
Citra.PixelFormat := pf24bit;
for i := 0 to 255 do begin
HistogramGray[i] := 0
end;
TotalPiksel := 0;
for brs := 0 to Citra.Height - 1 do begin
kol := 0;
piksel := Citra.ScanLine[brs];
repeat //greyscaling
R := 0.11*piksel[kol];
G := 0.59*piksel[kol+1];
B := 0.3*piksel[kol+2];
Gray := round(R+G+B);
HistogramGray[Gray] := histogramgray[Gray]+1; //
pengambilan data intensitas
inc(TotalPiksel);
Inc(kol,3);
until kol > 3*(Citra.Width-1);
end;
for kol:=0 to 255 do // normalisasi
HistogramGray[kol] := HistogramGray[kol]/TotalPiksel
end;