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);
i, j: integer;
Rcon,Gcon,Bcon : integer;
for i := 0 to FormHasil.ImgHasil.Picture.Height-1 do
PH:= FormHasil.ImgHasil.Picture.Bitmap.ScanLine[i];
for j:= 0 to FormHasil.ImgHasil.Picture.Width-1 do
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;


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…!!

Komentar FB

Probably Related Article


image editing services said...
May 21, 2009 at 10:32 PM

Great bit of information there. Thanks.

Karl said...
July 24, 2010 at 5:18 AM

Nice one mate, it have been long time ago when I had last touch with Delphi, probably around version six. Your tutorial was nice refreshing course for me.

Related Posts by Categories

Widget by