简介:

对目标区域进行轮廓提取,可以用于判定形状等。

介绍:

boundary(获取一个区域的边界)
Region (input_object)   Regions for which the boundary is to be computed. 区域
RegionBorder (output_object) Resulting boundaries. 输出的边界
BoundaryType (input_control)

Boundary type.
Default value: 'inner'
List of values: 'inner', 'inner_filled', 'outer'

linner 内边界。
inner_filled 内边界上的孔。
outer 外边界。
边界类型
gen_contour_region_xld(生成区域的XLD轮廓)
Regions (input_object)   Input regions. 区域
Contours (output_object)  Resulting contours. 输出的边界
Mode (input_control)  

Mode of contour generation.
Default value: 'border'
List of values: 'border', 'border_holes', 'center'

border 边界像素的外边界作为轮廓点。
border_holes 除了输入区域的外边界,还可以得到所有孔的轮廓。
center 边界像素的中心用作轮廓点。
轮廓生成方式
smallest_rectangle2_xld(任意方向的轮廓或多边形的最小外接矩形)
XLD (input_object) Contours or polygons to be examined. XLD
Row (output_control) Row coordinate of the center point of the enclosing rectangle. 输出的行坐标
Column (output_control)   Column coordinate of the center point of the enclosing rectangle. 输出的列坐标
Phi (output_control)   Orientation of the enclosing rectangle (arc measure).
Assertion: ((- pi / 2) < Phi) && (Phi <= (pi / 2))
弧度
Length1 (output_control)   First radius (half length) of the enclosing rectangle.
Assertion: Length1 >= 0.0
第一个边长
Length2 (output_control)   Second radius (half width) of the enclosing rectangle.
Assertion: (Length2 >= 0.0) && (Length2 <= Length1)
第二个边长
gen_rectangle2_contour_xld(创建一个矩形形状的XLD轮廓)
Rectangle (output_object)   Rectangle contour. 输出的矩形轮廓
Row (input_control)   Row coordinate of the center of the rectangle.
Default value: 300.0
行坐标
Column (input_control)   Column coordinate of the center of the rectangle.
Default value: 200.0
列坐标
Phi (input_control)   Orientation of the main axis of the rectangle [rad].
Default value: 0.0
Restriction: ((- pi / 2) < Phi) && (Phi <= (pi / 2))
弧度
Length1 (input_control)   First radius (half length) of the rectangle.
Default value: 100.5
第一个边长
Length2 (input_control) Second radius (half width) of the rectangle.
Default value: 20.5
第二个边长
segment_contours_xld(将XLD分割成线段和圆弧或椭圆圆弧)
Contours (input_object)  Contours to be segmented. 要分割的轮廓
ContoursSplit (output_object)   Segmented contours. 输出的分割轮廓
Mode (input_control)  Mode for the segmentation of the contours.
Default value: 'lines_circles'
List of values: 'lines', 'lines_circles', 'lines_ellipses'
轮廓分割模式
SmoothCont (input_control) Number of points used for smoothing the contours.
Default value: 5
Suggested values: 0, 3, 5, 7, 9
Restriction: (SmoothCont == 0) || ((SmoothCont >= 3) && odd(SmoothCont))
用于平滑轮廓的点的数目
MaxLineDist1 (input_control)   Maximum distance between a contour and the approximating line (first iteration).
Default value: 4.0
Suggested values: 1.0, 1.5, 2.0, 2.5, 3.0, 3.5
Restriction: MaxLineDist1 >= 0.0
第一次迭代时轮廓线与近似线之间的最大距离
MaxLineDist2 (input_control)  

Maximum distance between a contour and the approximating line (second iteration).
Default value: 2.0
Suggested values: 1.0, 1.5, 2.0, 2.5, 3.0, 3.5
Restriction: MaxLineDist2 >= 0.0

第二次迭代时轮廓线与近似线之间的最大距离
select_contours_xld(根据特征选择XLD轮廓)
Contours (input_object)  Input XLD contours. XLD轮廓
SelectedContours (output_object)  Output XLD contours. 输出的XDL轮廓
Feature (input_control)  

Feature to select contours with.
Default value: 'contour_length'
List of values: 'closed', 'contour_length', 'curvature', 'direction', 'maximum_extent', 'open'

closed 只返回起点和终点之间的距离小于或等于Max1像素的轮廓。(Min1、Min2和Max2在这里没有影响。)
contour_length 所有长度小于Min1或大于Max1的轮廓都不会返回(Min2和Max2在这里没有影响)。
curvature 只返回与回归线的平均距离在Min1和Max1之间、距离的标准差在Min2和Max2之间的轮廓。
direction 只返回回归线方向在Min1和Max1之间的等值线(以弧度为单位,逆时针方向)。Min1和Max1映射到[0,2*PI]的范围。(Min2和Max2在这里没有影响)。
maximum_extent 轮廓中最大的长度小于Min1或大于Max1不返回(Min2和Max2在这里没有影响)。
open 只返回起点和终点之间的距离大于Min1像素的轮廓线。(Max1、Min2和Max2在这里没有影响)。
特征选择
Min1 (input_control)   Lower threshold.
Default value: 0.5
最小值1
Max1 (input_control)   Upper threshold.
Default value: 200.0
最大值1
Min2 (input_control)   Lower threshold.
Default value: -0.5
最小值2
Max2 (input_control)   Upper threshold.
Default value: 0.5
最大值2
sort_contours_xld(轮廓排序)
Contours (input_object)  Contours to be sorted. 要排序的轮廓
SortedContours (output_object)  Sorted contours. 输出的排序轮廓
SortMode (input_control)  

Kind of sorting.
Default value: 'upper_left'
List of values: 'character', 'lower_left', 'lower_right', 'upper_left', 'upper_right'

character 位置由周围矩形的左上角决定。与'upper_left'相反,如果轮廓线与参数RowOrCol指定的坐标方向重叠,轮廓线也会根据剩余坐标进行排序。
lower_left 位置由周围矩形的左上角决定。
lower_right 位置由周围矩形的右上角决定。
upper_left 位置由周围矩形的左下角决定。
upper_right 位置由周围矩形的右下角决定。
排序种类
Order (input_control)  Increasing or decreasing sorting order.
Default value: 'true'
List of values: 'false', 'true'
减或增序
RowOrCol (input_control)   Sorting first with respect to row, then to column.
Default value: 'row'
List of values: 'column', 'row'
行或列
get_contour_global_attrib_xld(返回XLD轮廓的全局属性值)
Contour (input_object)  Input XLD contour. XLD轮廓
Name (input_control) Name of the attribute.
Default value: 'regr_norm_row'
Suggested values: 'regr_norm_row', 'regr_norm_col', 'regr_mean_dist', 'regr_dev_dist', 'cont_approx', 'bright_dark', 'is_hole'
属性名
Attrib (output_control)   Attribute values. 属性值
fit_line_contour_xld(用线段拟合XLD轮廓)
Contours (input_object)  Input contours. XLD轮廓
Algorithm (input_control)   Algorithm for the fitting of lines.
Default value: 'tukey'
List of values: 'drop', 'gauss', 'huber', 'regression', 'tukey'

drop “最小二乘”线拟合,其中的异常值被忽略。其中,所有距轮廓线较远的轮廓点,均忽略其到回归线的平均距离乘上(ClippingFactor),计算无畸变回归线。
gauss 加权“最小二乘”直线拟合,根据所有轮廓点到近似线距离的均值和标准差,减小异常值的影响。
huber 加权“最小二乘”线拟合,采用Huber方法减小了异常值的影响。
regression 标准最小二乘直线拟合。
tukey 加权“最小二乘”线拟合,基于Tukey方法忽略异常值。
直线拟合算法
MaxNumPoints (input_control)  

Maximum number of contour points used for the computation (-1 for all points).
Default value: -1
Restriction: MaxNumPoints >= 2

用于计算的最大轮廓点数量(-1表示所有点)
ClippingEndPoints (input_control) Number of points at the beginning and at the end of the contours to be ignored for the fitting.
Default value: 0
Restriction: ClippingEndPoints >= 0
拟合时忽略轮廓开始点和结束点的个数
Iterations (input_control)   Maximum number of iterations (unused for 'regression').
Default value: 5
Restriction: Iterations >= 0
最大迭代次数(regression不使用)
ClippingFactor (input_control) Clipping factor for the elimination of outliers (typical: 1.0 for 'huber' and 'drop' and 2.0 for 'tukey').
Default value: 2.0
List of values: 1.0, 1.5, 2.0, 2.5, 3.0
Restriction: ClippingFactor > 0
裁剪因子用于消除异常值(典型的:“huber”和“drop”时使用1,“tukey”时使用2)
RowBegin (output_control) Row coordinates of the starting points of the line segments. 线段起始点的行坐标
ColBegin (output_control)   Column coordinates of the starting points of the line segments. 线段起始点的列坐标
RowEnd (output_control)   Row coordinates of the end points of the line segments. 线段结束点的行坐标
ColEnd (output_control)   Column coordinates of the end points of the line segments. 线段结束点的列坐标
Nr (output_control) Line parameter: Row coordinate of the normal vector. 线参数:向量的行坐标
Nc (output_control)   Line parameter: Column coordinate of the normal vector. 线参数:向量的列坐标
Dist (output_control)  Line parameter: Distance of the line from the origin. 线参数:直线到原点的距离
gen_contour_polygon_xld(根据多边形的参数生成XDL轮廓)
Contour (output_object) Resulting contour. 输出的轮廓
Row (input_control)   Row coordinates of the polygon.
Default value: [0,1,2,2,2]
Suggested values: 0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500
行坐标
Col (input_control)  Column coordinates of the polygon.
Default value: [0,0,0,1,2]
Suggested values: 0, 1, 2, 3, 4, 5, 10, 20, 50, 100, 200, 500
列坐标

使用:

  1. 彩色图像要转成灰色图像。
  2. 通过阈值等方法获取目标区域。
  3. 获取区域的边界轮廓。
  4. 规则的形状可以使用最小外界矩形等获取形状的信息后画出形状。
  5. 不规则的可以对轮廓分段、选择、排序。获取轮廓线的属性,根据属性,获取坐标等然后拟合线(圆或椭圆)。
read_image (Image, 'E:/照片/轮廓.png')
decompose3 (Image, Image1, Image2, Image3)
trans_from_rgb (Image1, Image2, Image3, ImageResult1, ImageResult2, ImageResult3, 'hsv')
auto_threshold (ImageResult3, Regions, 2)
area_center (Regions, Area, Row, Column)
connection (Regions, ConnectedRegions)
count_obj (ConnectedRegions, Number)dev_set_draw ('margin')
for Index := 1 to Number by 1select_obj (ConnectedRegions, ObjectSelected, Index)area_center (ObjectSelected, Area1, Row1, Column1)*提取感兴趣的特征if (Area1 > 300 and Area1 < 500)dev_clear_window()dev_display (ObjectSelected)      boundary (ObjectSelected, RegionBorder, 'outer')     gen_contour_region_xld (RegionBorder, Contours, 'border')*规则形状-矩形smallest_rectangle2_xld (Contours, RowRec, ColumnRec, Phi1, LengthRec1, LengthRec2)gen_rectangle2_contour_xld (Rectangle, RowRec, ColumnRec, Phi1, LengthRec1, LengthRec2)*不规则形状-多边形segment_contours_xld (Contours, ContoursSplit, 'lines', 0, 0, 0)select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 0.5, 200, -0.5, 0.5)       sort_contours_xld (SelectedContours, SortedContours, 'upper_left', 'true', 'row')count_obj (SortedContours, Number1)gen_empty_obj (Lines)for Index1 := 1 to Number1 by 1select_obj (SortedContours, ObjectSelected1, Index1)get_contour_global_attrib_xld (ObjectSelected1, 'cont_approx', Attrib)*-1:线 0:椭圆 1:圆if (Attrib == -1)fit_line_contour_xld (ObjectSelected1, 'tukey', 2, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)gen_contour_polygon_xld (Polygon, [RowBegin,RowEnd], [ColBegin,ColEnd])concat_obj (Lines, Polygon, Lines)   endifendfor       breakendif
endfor
dev_clear_window ()
dev_display (Lines)

轮廓.png

矩形

不规则

Halcon轮廓提取相关推荐

  1. OpenCV(25)轮廓检测(轮廓提取、属性、近似轮廓、外接矩形和外接圆)

    目录 一.轮廓检测基础理论 1.轮廓概述 2.API介绍 1.cv.findContours函数(查找轮廓) 2.cv.drawContours函数(画出轮廓) 检测轮廓并画出:(用二值图检测轮廓) ...

  2. 边缘检测、Hough变换、轮廓提取、种子填充、轮廓跟踪

    转自:http://blog.sina.com.cn/s/blog_6c083cdd0100nm4s.html 7.1 边沿检测 我们给出一个模板 和一幅图象 .不难发现原图中左边暗,右边亮,中间存在 ...

  3. 基于深度学习的图像边缘和轮廓提取

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 导读:边缘和轮廓的提取是一个非常棘手的工作,细节也许就会被过强的图 ...

  4. 一种新型鱼眼图像轮廓提取算法

    from: http://www.scimao.com/read/2307651     摘 要:提取鱼眼图像轮廓是利用鱼眼图像的前提.传统提取鱼眼图像轮廓的扫描线逼近法对噪点抑制能力不强,精度差.本 ...

  5. python opencv轮廓提取_Python + Opencv2 实现轮廓提取,轮廓区域面积计算

    对图像处理时,会遇到这样一个场景:找到图像主体轮廓,这是其一,可能为了凸显轮廓,需要用指定的颜色进行标记:轮廓标记完可能任务还没有结束,还需对轮廓所勾勒的像素面积区域统计计算. 本篇文章的主要内容就是 ...

  6. 【OpenCV函数】轮廓提取;轮廓绘制;轮廓面积;外接矩形

    FindContours 在二值图像中寻找轮廓  int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_cont ...

  7. python cv2 轮廓的包络 面积_Python + Opencv2 实现轮廓提取,轮廓区域面积计算

    对图像处理时,会遇到这样一个场景:找到图像主体轮廓,这是其一,可能为了凸显轮廓,需要用指定的颜色进行标记:轮廓标记完可能任务还没有结束,还需对轮廓所勾勒的像素面积区域统计计算. 本篇文章的主要内容就是 ...

  8. Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法

    Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法 原文:Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法  [函数名称] 二值图像轮廓提取      ...

  9. 基于机器视觉的眼镜镜片轮廓提取

    基于机器视觉的眼镜镜片轮廓提取 眼镜的镜片轮廓提取,可以用于镜片轮廓本身的精准度测量,当然用在一些灰色产业链上,如仿制名牌眼镜,通过提取名牌眼镜片的轮廓,得到其数据,然后制作一些高仿的眼镜. 眼镜镜片 ...

最新文章

  1. Python内置数据结构之双向队列
  2. 【欧拉回路】解题报告:luogu P6066 [USACO]Watchcow (欧拉回路详解)【模板】
  3. Rust 语言风靡学术界
  4. QRadioButton分组且无边框的简单实现
  5. visual studio code跳转到定义处插件
  6. 下列代码的执行结果是 php,执行下列代码后的结果是: $x=15; echo $x++; $y=20; echo ++y;...
  7. java 编译器获得型号_关于编译器构造:如何找到已编译类的目标Java版本?
  8. 列举Python中常见的内置函数
  9. e7用什么主板_主板上这么多扩展插槽,都是干什么用的,看了不后悔
  10. 不用卷积也能生成清晰图像,用两个Transformer构建一个GAN
  11. 记一次Debian11安装
  12. python 异步执行多个函数_Python的asyncio模块写多个异步的执行顺序和影响?
  13. [RabbitMQ]MQ 的分类
  14. java课程设计进程管理_Java课设总结(个人版)
  15. linux 29900端口,USB2.0接口100M以太网芯片SR9900(A)的应用
  16. 实现手机版和电脑端显示不同的广告代码
  17. 在.net 当中如何XML序列化一个Collection
  18. datagrivew删除列_c# 如何获取datagrivew 表里面名称为card_id的一列,并把这列里面的元素循环...
  19. Adminlte数据分页设置
  20. 日立服务器显示地址操作异常,日立电梯服务器地址操作异常

热门文章

  1. 由己及人,由人及“机”
  2. 模拟电子技术基础------单管共射放大电路
  3. GCN—图卷积神经网络理解
  4. 用layui创建表格
  5. AltiumDesigner PCB 文件过大
  6. 声学模型训练----Acoustic Modeling
  7. 放大器指标:1db压缩点
  8. 编写文件服务器,编写服务器的头文件
  9. 北京做系统的公司有哪些服务器,北京服务器工控机排名
  10. python相对路径找不到文件_Python里使用相对路径的坑