其他分享
首页 > 其他分享> > halcon-闭运算(先膨胀后腐蚀)

halcon-闭运算(先膨胀后腐蚀)

作者:互联网

 

 

 

闭运算:对区域先进行膨胀操作,然后对膨胀的结果再进行膨胀操作,称为闭运算
闭运算特点:具有与膨胀相似的特点,但是能够防止区域膨胀过度,能够很好的保持区域的形状。

效果:能填补缝隙

closing_circle区域圆闭运算

在HDevelop中

dev_update_off()

read_image (Image, 'D:/bb/tu/3.jpg')
rgb1_to_gray(Image,Image1)

threshold (Image1, Region, 200, 230)
closing_circle (Region, RegionClosing, 3.5)
*区域圆闭运算
*参数1:要闭运算的区域
*参数2:输出区域
*结构圆半径


get_image_size (Image1, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle)
dev_display(Region)
dev_open_window(10,100,Width, Height,'black',WindowHandle1)
dev_display(RegionClosing)

 

 


在Qt Creator中

    HObject  ho_Image, ho_Image1, ho_Region, ho_RegionClosing;
    HTuple  hv_Width, hv_Height, hv_WindowHandle;
    HTuple  hv_WindowHandle1;
    ReadImage(&ho_Image, "D:/bb/tu/3.jpg");
    Rgb1ToGray(ho_Image, &ho_Image1);

    Threshold(ho_Image1, &ho_Region, 200, 230);
    ClosingCircle(ho_Region, &ho_RegionClosing, 3.5);
    //区域圆闭运算
    //参数1:要闭运算的区域
    //参数2:输出区域
    //结构圆半径


    GetImageSize(ho_Image1, &hv_Width, &hv_Height);
    SetWindowAttr("background_color","black");
    OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle);
    HDevWindowStack::Push(hv_WindowHandle);
    if (HDevWindowStack::IsOpen())
      DispObj(ho_Region, HDevWindowStack::GetActive());
    SetWindowAttr("background_color","black");
    OpenWindow(10,100,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1);
    HDevWindowStack::Push(hv_WindowHandle1);
    if (HDevWindowStack::IsOpen())
      DispObj(ho_RegionClosing, HDevWindowStack::GetActive());

 

 

 

 

 

 

标签:运算,Region,hv,halcon,Width,腐蚀,ho,Image1,Height
来源: https://www.cnblogs.com/liming19680104/p/15978926.html