halcon-edges_sub_pix亚像素边缘

XLD

halcon中什么是XLD?

XLD(eXtended Line Descriptions):换句话说XDL就是一个轮廓函数,它不是基于像素,人们通常称他为亚像素,只不过它比像素更精确,可以精确到像素内部的一种描述。
在Halcon中,使用XLD表示亚像素的轮廓和多边形。常用edges_sub_pix算子来提取亚像素轮廓。
我们都知道图片是由像素组成,当我们用halcon读取图像Image或者region的时候,获得的数据就是像素。这些数据结构都是像素级别的。
获得图像后,我们可以通过亚像素阈值分割或者亚像素边缘提取,这样这些处理得到的结果其实就是用亚像素轮廓来表示。。
上述所述亚像素轮廓其实在halcon中指的就是xld,它可以表示直线或多边形,是一组有序的控制点集合,控制点顺序用来说明彼此相连的关系。

亚像素的轮廓可以分为两种:
1.闭轮廓:首尾相交
2.开轮廓:首尾不相交

 

 

 

在HDevelop中

复制代码
dev_close_window ()
read_image (Image, 'D:/bb/tu/1.jpg')
rgb1_to_gray (Image, GrayImage)

edges_sub_pix (GrayImage, Edges, 'canny', 1, 20, 40)
*亚像素边缘
*参数1:输入图像
*参数2:输出xld
*参数3:边缘算子
*       'canny'
*       'canny_junctions'
*       'deriche1'
*       'deriche1_junctions'
*       'deriche2'
*       'deriche2_junctions'
*       'lanser1'
*       'lanser1_junctions'
*       'lanser2'
*       'lanser2_junctions'
*       'mshen'
*       'mshen_junctions'
*       'shen', 'shen_junctions'
*       'sobel', 'sobel_fast', 'sobel_junctions'
*参数4:迭代次数,小的值导致强平滑,但是更少的细节(canny算子相反)
*参数5:低阈值(如果不需要阈值设置,则为负值)
*参数6:高阈值(如果不需要阈值设置,则为负值),高阈值一般是低阈值的1.5-2倍
*【灰度值差在参数5和参数6之间的被忽略】



get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle)
dev_display(Edges)

dev_open_window(10,10,Width, Height,'black',WindowHandle1)
dev_display(GrayImage)
复制代码

 

 


在QtCreator中

  HObject  ho_Image, ho_GrayImage, ho_Edges;
  HTuple  hv_Width, hv_Height, hv_WindowHandle;
  HTuple  hv_WindowHandle1;
复制代码
  ReadImage(&ho_Image, "D:/bb/tu/1.jpg");
  Rgb1ToGray(ho_Image, &ho_GrayImage);

  EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 20, 40);
  //亚像素边缘
  //参数1:输入图像
  //参数2:输出xld
  //参数3:边缘算子
  //      'canny'
  //      'canny_junctions'
  //      'deriche1'
  //      'deriche1_junctions'
  //      'deriche2'
  //      'deriche2_junctions'
  //      'lanser1'
  //      'lanser1_junctions'
  //      'lanser2'
  //      'lanser2_junctions'
  //      'mshen'
  //      'mshen_junctions'
  //      'shen', 'shen_junctions'
  //      'sobel', 'sobel_fast', 'sobel_junctions'
  //参数4:迭代次数,小的值导致强平滑,但是更少的细节(canny算子相反)
  //参数5:低阈值(如果不需要阈值设置,则为负值)
  //参数6:高阈值(如果不需要阈值设置,则为负值),高阈值一般是低阈值的1.5-2倍
  //【灰度值差在参数5和参数6之间的被忽略】



  GetImageSize(ho_GrayImage, &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_Edges, HDevWindowStack::GetActive());

  SetWindowAttr("background_color","black");
  OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1);
  HDevWindowStack::Push(hv_WindowHandle1);
  if (HDevWindowStack::IsOpen())
    DispObj(ho_GrayImage, HDevWindowStack::GetActive());
复制代码

 

 

 

 

posted @   天子骄龙  阅读(2078)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
历史上的今天:
2019-03-13 C++ 成员指针---了解
点击右上角即可分享
微信分享提示

目录导航