Minggu, 03 Mei 2009

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

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

(1. Normal Image)

(2. Increase Contrast, Histogram Spread)

(3. Decrease Contrast, Histogram Collect)

Below is Source Code for Contrast Image Processing in Delphi.


Procedure TFormBright_Con.Contrast(N:integer);
var
i, j: integer;
Rcon,Gcon,Bcon : 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
Rcon:= Round((PH[3*j]/255)*(255-(2*N))+ N);
Gcon:= Round((PH[3*j+1]/255)*(255-(2*N))+ N);
Bcon:= Round((PH[3*j+2]/255)*(255-(2*N))+ N);

if Rcon >255 Then Rcon:=255
else if Rcon<0 Then Rcon:=0;
if Gcon>255 then Gcon:=255
else if Gcon<0 Then Gcon:=0;
if Bcon>255 then Bcon:=255
else if Bcon<0 Then Bcon:=0;

PH[3*j] := Rcon;
PH[3*j+1] := Gcon;
PH[3*j+2] := Bcon;

end;
end;
end;




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

Example :

Contrast (TrackBar.Position);

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

1 komentar:

image editing services mengatakan...

Great bit of information there. Thanks.