halcon的图像旋转(区域旋转)
关键算子:
orientation_region
vector_angle_to_rigid
affine_trans_region
测试图片:
halcon代码:
*此例子将图中没有偏移的形状参照旋转的形状进行旋转
read_image (Image, 'D:/Halcon-WorkSpaces/Test/Image/test14.png')
rgb1_to_gray (Image, GrayImage)
*获取旋转的矩形
threshold (GrayImage, Regions, 0, 0)
*计算区域斜率
orientation_region (Regions, Phi)
*获取没有旋转的矩形
threshold (GrayImage, Regions1, 100, 140)
area_center (Regions1, Area, Row, Column)
*创建变换模型
vector_angle_to_rigid (Row, Column, 0, Row, Column, Phi, HomMat2D)
*区域变换
affine_trans_region (Regions1, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
dev_clear_window ()
dev_display (RegionAffineTrans)
dev_display (Regions)
效果:
赞 (0)