Minggu, 03 Mei 2009

Grayscale Image Processing and Source Code In Delphi

Hi Friend. Do You need Source Code of Image Processing..? But I’m only have in Delphi Programming. It is easy to Follow and Understand.

Pixel in Grayscale Image Basically obtain from dividing by three the Red + Green + Blue Pixels. Or the sum of Component Red + Green + Blue Must be One (1).
Example : 0.33 * R + 0.33 G + 0.33 B


Below is Source Code for Grayscale Image Processing in Delphi.


procedure TForm1.ToolButtonGrayscaleClick(Sender: TObject);
var
i, j : integer;
Grey : Integer;
PH : PByteArray;
begin
for i:=0 to FormHasil.ImgHasil.Height-1 do
begin
PH:=FormHasil.ImgHasil.Picture.Bitmap.ScanLine[i];
for j:=0 to FormHasil.ImgHasil.Width-1 do
begin
Grey := Round ((PH[3*J] + PH[3*J+1] + PH[3*J+2] ) / 3);
PH[3*j]:= Grey;
PH[3*j+1]:= Grey;
PH[3*j+2]:= Grey;
end;
end;
FormHasil.ImgHasil.Repaint;
FormHistogram.Histogram;
end;



Please Comment If I’m Wrong. Comment are widely open…!!
Related Post:

Tidak ada komentar: