39.
Randy Crane. A simplified approach to image processing. Classical and
modern techniques in c. Prentice Hall PTR. Upper Saddle River. New Jersey
07458. 1997.
66
ILOVA
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ExtDlgs, Menus, StdCtrls, Spin, ComCtrls;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Fayl1: TMenuItem;
GorKon1: TMenuItem;
VerKon1: TMenuItem;
Usullar1: TMenuItem;
GorKon2: TMenuItem;
Verkon2: TMenuItem;
OpenPictureDialog1: TOpenPictureDialog;
SavePictureDialog1: TSavePictureDialog;
Image1: TImage;
Image2: TImage;
SpinEdit1: TSpinEdit;
MaskaUsuli1: TMenuItem;
RobertsUsuli1: TMenuItem;
SobelUsuli1: TMenuItem;
UollisUsuli1: TMenuItem;
N4541: TMenuItem;
Dasturdanchiqish1: TMenuItem;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
yar1: TMenuItem;
PoliTon1: TMenuItem;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Image3: TImage;
SkeletOlish1: TMenuItem;
Faylgayozish1: TMenuItem;
SpinEdit2: TSpinEdit;
Button4: TButton;
Button5: TButton;
Image4: TImage;
67
Masshtablash1: TMenuItem;
Masshtablash11: TMenuItem;
Masshtablsh21: TMenuItem;
Sifatinioshirish1: TMenuItem;
Yarkost1: TMenuItem;
iniqlashtirish1: TMenuItem;
N5x5ni3x3gaotkazish1: TMenuItem;
Label1: TLabel;
Button6: TButton;
SpinEdit3: TSpinEdit;
Label2: TLabel;
Button8: TButton;
Chizqli1: TMenuItem;
SpinEdit4: TSpinEdit;
Button7: TButton;
Button9: TButton;
PoliTon21: TMenuItem;
Label3: TLabel;
Normallashtirish1: TMenuItem;
Button10: TButton;
SpinEdit5: TSpinEdit;
Segmentasiya1: TMenuItem;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
SpinEdit6: TSpinEdit;
SpinEdit7: TSpinEdit;
SpinEdit8: TSpinEdit;
Belgilarnishakllantirish1: TMenuItem;
Masofa11: TMenuItem;
Aylana1: TMenuItem;
Maydanuqtalarniyuqotish1: TMenuItem;
Nuqtanitopish1: TMenuItem;
Masofa21: TMenuItem;
Masofa31: TMenuItem;
asvirniburish1: TMenuItem;
Histogramma1: TMenuItem;
PopupMenu1: TPopupMenu;
Nuqta11: TMenuItem;
Aylana2: TMenuItem;
Aylana3: TMenuItem;
eriranginiajratish1: TMenuItem;
68
eshiklarnitoldirish1: TMenuItem;
Label9: TLabel;
NuqtaniMaxMin1: TMenuItem;
AylanaMarkaz1: TMenuItem;
Memo1: TMemo;
procedure GorKon1Click(Sender: TObject);
procedure GorKon2Click(Sender: TObject);
procedure Verkon2Click(Sender: TObject);
procedure MaskaUsuli1Click(Sender: TObject);
procedure RobertsUsuli1Click(Sender: TObject);
procedure SobelUsuli1Click(Sender: TObject);
procedure UollisUsuli1Click(Sender: TObject);
procedure VerKon1Click(Sender: TObject);
procedure Dasturdanchiqish1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure PoliTon1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure N4541Click(Sender: TObject);
procedure SkeletOlish1Click(Sender: TObject);
procedure Faylgayozish1Click(Sender: TObject);
procedure Masshtablash11Click(Sender: TObject);
procedure Masshtablsh21Click(Sender: TObject);
procedure Yarkost1Click(Sender: TObject);
procedure iniqlashtirish1Click(Sender: TObject);
procedure N5x5ni3x3gaotkazish1Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Chizqli1Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure PoliTon21Click(Sender: TObject);
procedure Normallashtirish1Click(Sender: TObject);
procedure Segmentasiya1Click(Sender: TObject);
procedure Image4MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Image3MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Masofa11Click(Sender: TObject);
procedure Aylana1Click(Sender: TObject);
procedure Nuqtanitopish1Click(Sender: TObject);
procedure Masofa21Click(Sender: TObject);
procedure Masofa31Click(Sender: TObject);
procedure Histogramma1Click(Sender: TObject);
69
procedure Nuqta11Click(Sender: TObject);
procedure Image3MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Aylana3Click(Sender: TObject);
procedure eriranginiajratish1Click(Sender: TObject);
procedure eshiklarnitoldirish1Click(Sender: TObject);
procedure NuqtaniMaxMin1Click(Sender: TObject);
procedure AylanaMarkaz1Click(Sender: TObject);
procedure asvirniburish1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
F: Text;
X1,Y1,X2,Y2:integer;
F1:TextFile;
implementation
{$R *.dfm}
procedure TForm1.PoliTon1Click(Sender: TObject);
var
r,g,b: byte;
i,j,m,n,Urt,Urt1: integer;
begin
Label3.Caption:='Kulrang';
Image2.Width:=Image1.Width;
Image2.Height:=Image1.Height;
m:=Image2.Picture.Width ;
n:=Image2.Picture.Height;
for i:=0 to m-1 do
for j:=0 to n-1 do
begin
70
R:=GetRvalue(Image2.Canvas.Pixels[i,j]);
G:=GetRvalue(Image2.Canvas.Pixels[i,j]);
B:=GetRvalue(Image2.Canvas.Pixels[i,j]);
Urt:=(R+G+B) div 3;
Urt1:=Round(Urt);
Image2.Canvas.Pixels[i,j]:=RGB(Urt1,Urt1,Urt1);
end;
end;
procedure TForm1.PoliTon21Click(Sender: TObject);
var
r,g,b: byte;
i,j,m,n,z: integer;
Urt: real;
begin
Label3.Caption:='Kulrang';
Image3.Width:=Image1.Width;
Image3.Height:=Image1.Height;
m:=Image1.Picture.Width ;
n:=Image1.Picture.Height;
for i:=0 to m-1 do
for j:=0 to n-1 do
begin
R:=GetRvalue(Image1.Canvas.Pixels[i,j]);
G:=GetRvalue(Image1.Canvas.Pixels[i,j]);
B:=GetRvalue(Image1.Canvas.Pixels[i,j]);
Urt:=(0.3*R+0.59*G+0.11*B);
Z:=Round(Urt);
Image3.Canvas.Pixels[i,j]:=RGB(z,z,z);
71
end;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Button1: TButton;
GroupBox2: TGroupBox;
bvl1: TBevel;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
GroupBox3: TGroupBox;
Image1: TImage;
Image2: TImage;
OpenPictureDialog1: TOpenPictureDialog;
SavePictureDialog1: TSavePictureDialog;
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ImgMas : array of array of Byte;
implementation
{$R *.dfm}
procedure GrayScale(var clip: tbitmap);
var
p0:pbytearray;
72
Gray,x,y: Integer;
begin
SetLength(ImgMas,clip.Width,clip.Height);
for y:=0 to clip.Height-1 do
begin
p0:=clip.scanline[y];
for x:=0 to clip.Width-1 do
begin
Gray:=Round(p0[x*3]*0.3+p0[x*3+1]*0.59+p0[x*3+2]*0.11);
p0[x*3]:=Gray;
p0[x*3+1]:=Gray;
p0[x*3+2]:=Gray;
ImgMas[x,y]:=Gray;
end;
end;
ShowMessage('sdf');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
BMP : TBitmap;
begin
BMP:=TBitMap.Create;
BMP.Assign(Image1.Picture.Bitmap);
GrayScale(BMP);
Image2.Picture.Assign(BMP);
BMP.Free;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
end.
Do'stlaringiz bilan baham: |