halcon学习 matching基础的transformation

转载:http://qing.blog.sina.com.cn/2316220871/8a0eb9c733002r5h.html


halcon提供了各种转换操作,针对于2D匹配方法可以使用2D affine transformmtion,它允许位移,转动或者按比例改变大小。对于色彩空间透视图匹配(uncalibrated perspective matching)方法,2D投影转换可以用来改变投影视角,除此之外,还有3D affine transformations。


1,  2 D仿射转换
位移,转动,尺度变化:
注意对于转动和尺度变化,需要一个固定参考点来实行。

halcon允许对pixels,regions,images以及XLD contours进行2D转换,具体可用:
affine_trans_pixel,  affine_trans_region,   affine_trans_image,  affine_trans_contour_xld


halcon学习 matching基础的transformation_第1张图片
eg:   affine_trans_region (IC, TransformedIC, ScalingRotationTranslation,          'nearest_neighbor')

这当中的参数ScalingRotationTranslation就是所谓的齐次转换矩阵(homogeneous transformation matrix),用来描述想要进行的转换(包含了转换的信息)。对于这个矩阵的生成,
可以用如下步骤进行创建齐次转换矩阵:
step1:创建一个单位矩阵(identity matrix)
hom_mat2d_identity(EmptyTransformation)   // 创建

step2:这里比如说,添加一个对于IC的中心点的scaling变化
hom_mat2d_scale( EmptyTransformation, 0.5, 0.5, RowCenterIC, ColumnCenterIC, Scaling)                      // 对单位矩阵进行变化,添加转变信息

如果要添加转动或者位移信息,可以用hom_mat2d_rotate 和 hom_mat2d_translate来实现
hom_mat2d_rotate (Scaling, rad(90), RowCenterIC, ColumnCenterIC, \
ScalingRotation)
hom_mat2d_translate (ScalingRotation, 100, 200, ScalingRotationTranslation)

注意这里的转换矩阵是可以逆推得来的,如果已知对象(比如说region)的原状态(或者是某些特定点的位置)和转换之后的状态,那么可以通过反推来得到转换矩阵,从而根据转换矩阵来计算转换前的对象状态(region)
vector_angle_to_rigid (RowCenterIC, ColumnCenterIC, 0, \
                                     TransformedRowCenterIC, TransformedColumnCenterIC, \
                                    rad(90), RotationTranslation)
affine_trans_region (IC, TransformedIC, RotationTranslation, \
                                   'nearest_neighbor')

vector_angle_to_rigid就是逆推的过程,其结果可以直接用作转换矩阵来得出转换前的状态


2,2D透视转换
3×3的一个矩阵就可以完成上面步骤中的2D仿射转换,当最后一行是[0 ,0 ,1]时候,就是一个齐次转换矩阵,描述了一个2D仿射转换,这也是2D透视转换的一种特殊情况。

像仿射转换一样,halcon中,可以用一个射影转换来实现不同对象的透视转换:
pixels(projective_trans_pixel), regions(projective_trans_region), images(projective_trans_image), XLD contours( prejective_trans_contour_xld).

下面根据solution中 section 2.4.5(page 51)来认识2D透视转换:

2.4.5 Use the Estimated 2D Homography
当使用色彩空间透视匹配方法时候,仅仅返回透视转换矩阵(但是位置,角度,尺度辛迪都不返回)。
两个透视转换匹配的例子,见后面博客(halcon例子学习matching路牌 和halcon例子学习matching纸张
HDevelop example program hdevelop\Applications\Traffic-
Monitoring\detect_road_signs.hdev
HDevelop example program hdevelop\Applications\Object-Recognition-2D\
detect_brochure_pages.hdev

3,3D透视转换不做具体介绍。

你可能感兴趣的:(halcon,学习,halcon,学习)