其他分享
首页 > 其他分享> > halcon-fill_up_shape填充区域或区域集中具有给定形状特征的孔

halcon-fill_up_shape填充区域或区域集中具有给定形状特征的孔

作者:互联网

 

 

在HDevelop中

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

threshold (Image1, Region,[190,85,105] , [205,100, 115])

fill_up_shape (Region, RegionFillUp, 'area', 1, 10000)
*填充输入区域或区域集中具有给定形状特征的那些孔
*参数1:输入区域或区域集
*参数2:输出区域
*参数3:形状特征
*       'anisometry'
*       'area'             面积
*       'compactness'      紧密度
*       'convexity'
*       'inner_circle'     内切圆
*       'outer_circle'     外切圆
*       'phi'
*       'ra'
*       'rb'
*参数4:特征的最小值
*参数5:特征的最大值



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(RegionFillUp)

 

 

 


在Qt Creator中

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

  Threshold(ho_Image1, &ho_Region, ((HTuple(190).Append(85)).Append(105)), ((HTuple(205).Append(100)).Append(115)));

  FillUpShape(ho_Region, &ho_RegionFillUp, "area", 1, 10000);
  //填充输入区域或区域集中具有给定形状特征的那些孔
  //参数1:输入区域或区域集
  //参数2:输出区域
  //参数3:形状特征
  //      'anisometry'
  //      'area'             面积
  //      'compactness'      紧密度
  //      'convexity'
  //      'inner_circle'     内切圆
  //      'outer_circle'     外切圆
  //      'phi'
  //      'ra'
  //      'rb'
  //参数4:特征的最小值
  //参数5:特征的最大值



  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_RegionFillUp, HDevWindowStack::GetActive());

 

 

 

 

标签:Region,hv,up,halcon,Width,shape,ho,Image1,Height
来源: https://www.cnblogs.com/liming19680104/p/15987898.html