zw版【转发·台湾nvp系列Delphi例程】HALCON SqrtImage
HALCON SqrtImage 範例 (RAD Studio XE Delphi x64)

zw版【转发·台湾nvp系列Delphi例程】HALCON SqrtImage-LMLPHP

zw版【转发·台湾nvp系列Delphi例程】HALCON SqrtImage

(RAD Studio XE Delphi x64)

SqrtImage_Delphi_XE4_Win64.png

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
AxHALCONXLib_TLB, HALCONXLib_TLB;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
Panel2: TPanel;
Panel3: TPanel;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
op: HOperatorSetX;
HWindowX1, HWindowX2, HWindowX3: HWindowX;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
image0, image1: HImageX;
w, h: OleVariant;
begin
HWindowX1.ClearWindow;
HWindowX2.ClearWindow;
HWindowX3.ClearWindow;
image0 := CoHImageX.Create;
image0.ReadImage('monkey');
w := image0.GetImageSize(h);
HWindowX1.SetPart(0, 0, h - 1, w - 1);
image0.DispObj(HWindowX1);
image1 := image0.SqrtImage;
HWindowX2.SetPart(0, 0, h - 1, w - 1);
image1.DispObj(HWindowX2);
HWindowX2.SetTposition(10, 10);
HWindowX2.WriteString('SqrtImage');
image1 := image0.SigmaImage(4, 4, 3);
HWindowX3.SetPart(0, 0, h - 1, w - 1);
image1.DispObj(HWindowX3);
HWindowX3.SetTposition(10, 10);
HWindowX3.WriteString('MaskHeight X MaskWidth : 4 X 4');
HWindowX3.SetColor('red');
HWindowX3.SetTposition(50, 10);
HWindowX3.WriteString('偶数值:4 X 4 => 奇数值:5 X 5');
HWindowX3.SetColor('white');
HWindowX3.SetTposition(90, 10);
HWindowX3.WriteString('MaskHeight X MaskWidth : 5 X 5');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
op.CloseWindow(HWindowX1.HalconID);
op.CloseWindow(HWindowX2.HalconID);
op.CloseWindow(HWindowX3.HalconID);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Self.Caption := Self.Caption + ' Delphi ' + IntToStr(Sizeof(Pointer) * 8);
op := CoHOperatorSetX.Create;
op.SetCheck('~father');
HWindowX1 := CoHWindowX.Create();
HWindowX2 := CoHWindowX.Create();
HWindowX3 := CoHWindowX.Create();
HWindowX1.OpenWindow(0, 0, Panel1.ClientWidth, Panel1.ClientHeight,
Int64(Panel1.Handle), 'visible', '');
HWindowX2.OpenWindow(0, 0, Panel2.ClientWidth, Panel2.ClientHeight,
Int64(Panel2.Handle), 'visible', '');
HWindowX3.OpenWindow(0, 0, Panel3.ClientWidth, Panel3.ClientHeight,
Int64(Panel3.Handle), 'visible', '');
end;
end.

------------
(Delphi)
procedure TForm1.Button1Click(Sender: TObject);
var
image0, image1 : HImageX;
w, h : OleVariant;
begin
HWindowXCtrl1.HalconWindow.ClearWindow;
HWindowXCtrl2.HalconWindow.ClearWindow;
HWindowXCtrl3.HalconWindow.ClearWindow;
image0 := CoHImageX.Create;
image0.ReadImage('monkey');
w := image0.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
image0.DispObj(HWindowXCtrl1.HalconWindow);
image1 := image0.SqrtImage;
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
image1.DispObj(HWindowXCtrl2.HalconWindow);
HWindowXCtrl2.HalconWindow.SetTposition(10, 10);
HWindowXCtrl2.HalconWindow.WriteString('SqrtImage');

image1 := image0.SigmaImage(4, 4, 3);
HWindowXCtrl3.HalconWindow.SetPart(0, 0, h - 1, w - 1);
image1.DispObj(HWindowXCtrl3.HalconWindow);
HWindowXCtrl3.HalconWindow.SetTposition(10, 10);
HWindowXCtrl3.HalconWindow.WriteString('MaskHeight X MaskWidth : 4 X 4');
HWindowXCtrl3.HalconWindow.SetColor('red');
HWindowXCtrl3.HalconWindow.SetTposition(50, 10);
HWindowXCtrl3.HalconWindow.WriteString('偶數值:4 X 4 => 奇數值:5 X 5');
HWindowXCtrl3.HalconWindow.SetColor('white');
HWindowXCtrl3.HalconWindow.SetTposition(90, 10);
HWindowXCtrl3.HalconWindow.WriteString('MaskHeight X MaskWidth : 5 X 5');
end;

05-18 09:07