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

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

 

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;
type
TForm1 = class(TForm)
HWindowXCtrl1: THWindowXCtrl;
Button1: TButton;
HWindowXCtrl2: THWindowXCtrl;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
img : HImageX;
rg : HRegionX;
w, h : OleVariant;
begin
img := CoHImageX.Create;
img.ReadImage('circle_plate');
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl1.HalconWindow);

rg := img.Threshold(0, 60);
img := rg.RegionToBin(255, 0, w, h);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl2.HalconWindow);
end;
end.

 

posted @ 2015-10-01 16:31  统领  阅读(357)  评论(0编辑  收藏  举报