zw版【转发·台湾nvp系列Delphi例程】HALCON SmoothImage
procedure TForm1.Button1Click(Sender: TObject);
var
image0, image1, result : HImageX;
w , h : OleVariant;
i : Integer;
r, c : Integer;
begin
image0 := CoHImageX.Create;
image0.ReadImage(‘fuse‘);
w := image0.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
image0.DispObj(HWindowXCtrl1.HalconWindow);
image1 := image0.CopyImage;
Randomize;
for i := 1 to 1000 do
begin
r := Random(Integer(h));
c := Random(Integer(w));
image1.SetGrayval(r, c, Random(255));
end;
w := image1.GetImageSize(h);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
image1.DispObj(HWindowXCtrl2.HalconWindow);
result := image1.SmoothImage(‘deriche2‘, 0.5);
w := result.GetImageSize(h);
HWindowXCtrl3.HalconWindow.SetPart(0, 0, h - 1, w - 1);
result.DispObj(HWindowXCtrl3.HalconWindow);
end;