目录
1,halcon图像格式
2,不同格式之间相互转换的方法
convert_image_type (Image1, ImageInt4, 'int4')
3,halcon常见数据存储方法
转载:
Halcon中三种图像数据类型的存储方式_贾路飞的博客-CSDN博客_halcon保存图片
-
XLD像素坐标值的存储方式
根据如下代码,将上面的Region转换为XLD,并获取该XLD上所有像素的坐标值,根据结果可以看出,XLD上像素坐标值是按照顺时针的顺序依次存储的。
gen_contour_region_xld (ROI_0, Contours, 'border')
get_contour_xld (Contours, Row, Col)
-
Polygon像素坐标值的存储方式
根据如下代码,生成一个区域,先转换为XLD再转换为Polygon,并获取该Polygon上所有像素的坐标值,根据结果可以看出,Polygon上像素坐标值是按照顺时针的顺序依次存储的,并且是一些列离散的点集(只有在拐角处会存在点)
gen_region_runs (ROI_0, [140,141,142,143,143,144,145,146,147,148,149,150,151,151,152,152,153,153,154,154,155,155,156,156,157,157,158], [189,187,185,172,183,166,164,162,161,160,158,157,156,171,155,170,154,169,154,169,153,168,153,168,168,184,168], [189,189,189,180,189,189,189,189,189,189,189,189,166,189,163,189,161,189,159,189,157,189,155,189,175,189,168])
gen_contour_region_xld (ROI_0, Contours, 'border')
gen_polygons_xld (Contours, Polygons, 'ramer', 2)
get_polygon_xld (Polygons, Row, Col, Length, Phi)
gen_region_points (Region, Row, Col)
-
Region、XLD、Polygon之间的相关转换
当我们检测不连续的划痕缺陷时,通过边缘检测算子得到的xld也是不连续的。这时我们可以将不连续的xld合并为一个整体,但是我们将这个合并后的xld转换为region后,region已经不是一条线而是一个闭合的区域。
read_image (Image, 'C:/Users/SWD-AR05/Desktop/10.png')
lines_gauss (Image, Lines, 1.5, 3, 8, 'dark', 'true', 'bar-shaped', 'true')
union_adjacent_contours_xld (Lines, UnionContours, 100, 10, 'attr_keep')
gen_region_contour_xld (UnionContours, Region, 'filled')
针对上述问题,我们可以先将合并后的xld转换为polygon,然后将polygon转换为region,此时region就是一条连续的线。
read_image (Image, 'C:/Users/SWD-AR05/Desktop/10.png')
lines_gauss (Image, Lines, 1.5, 3, 8, 'dark', 'true', 'bar-shaped', 'true')
union_adjacent_contours_xld (Lines, UnionContours, 100, 10, 'attr_keep')
gen_polygons_xld (UnionContours, Polygons, 'ramer', 2)
get_polygon_xld (Polygons, Row, Col, Length, Phi)
gen_region_polygon (Region1, Row, Col)