zw版【转发·*nvp系列Delphi例程】HALCON BinThreshold

时间:2022-04-25 00:25:22

zw版【转发·*nvp系列Delphi例程】HALCON BinThreshold

zw版【转发·*nvp系列Delphi例程】HALCON BinThreshold

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, HALCONXLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
HWindowXCtrl1: THWindowXCtrl;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
Set8087CW($27f);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ho_Egypt1 : HImageX;
ho_Region : HRegionX;
ho_Histo1 : HRegionX;
hv_AbsoluteHisto, hv_RelativeHisto : OleVariant;
win : HWindowX;
mtype : OleVariant;
w, h : OleVariant;
begin
win := HWindowXCtrl1.HalconWindow;
ho_Egypt1 := CoHImageX.Create;
ho_Egypt1.ReadImage('egypt1');
ho_Egypt1.GetImagePointer1(mtype, w, h);
win.SetPart(0, 0, h - 1, w - 1);
win.SetColor('white');
win.ClearWindow;
ho_Region := ho_Egypt1.BinThreshold;
ho_Region.DispObj(win);
hv_AbsoluteHisto := ho_Region.GrayHisto(ho_Egypt1, hv_RelativeHisto);
ho_Histo1 := CoHRegionX.Create;
ho_Histo1.GenRegionHisto(hv_RelativeHisto, 255, 255, 1);
win.SetColor('red');
ho_Histo1.DispObj(win);
end;
end.