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

halcon-开运算(先腐蚀再膨胀)

作者:互联网

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

opening_circle区域圆开运算 

在HDevelop中

dev_update_off()

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

threshold (Image1, Region, 200, 230)
opening_circle (Region, RegionOpening, 2.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(RegionOpening)

 

 

在QtCreator中

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

    Threshold(ho_Image1, &ho_Region, 200, 230);
    OpeningCircle(ho_Region, &ho_RegionOpening, 2.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_RegionOpening, HDevWindowStack::GetActive());

 

 

 

 

 

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