Selasa, 28 April 2009

Brightness 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.

Brightness manipulation is widely use in image processing. We give a value to the procedure to change the brightness. Positive value mean increase brighness and negative value mean decrease brightness.

(a. normal image)

(b. decrease brightness, histogram spread)


(c. increase brightness 1, histogram collect together in right side)

(d. increase brightness 2, histogram collect together in right side)


Below is Source Code for Brightness Image Processing in Delphi.


procedure TFormBright_Con.Brightness (A:integer);
var
i, j: integer;
R,G,B : integer;
PH:PByteArray;
begin
for i:= 0 to FormHasil.ImgHasil.Picture.Height-1 do
begin
PH:= FormHasil.ImgHasil.Picture.Bitmap.ScanLine[i];
for j:= 0 to FormHasil.ImgHasil.Picture.Width-1 do
begin
R:= A + round((PH[3*j]/255)*(255-A));
G:= A + round((PH[3*j+1]/255)*(255-A));
B:= A + round((PH[3*j+2]/255)*(255-A));

if R >255 Then R:=255
else if R<0 Then R:=0;
if G>255 then G:=255
else if G<0 Then G:=0;
if B>255 then B:=255
else if B<0 Then B:=0;

PH[3*j] := R;
PH[3*j+1] := G;
PH[3*j+2] := B;

end;
end;
end;




Please pass the value from SpinEdit Maybe or by TrackBar or manualy by Edit.
Example :

Brightness(TrackBar.Position);

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

Tidak ada komentar: