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…!!
Tidak ada komentar:
Posting Komentar