halcon的图像旋转(区域旋转)

关键算子:

orientation_region

vector_angle_to_rigid

affine_trans_region

测试图片:

halcon代码:

  1. *此例子将图中没有偏移的形状参照旋转的形状进行旋转
  2. read_image (Image, 'D:/Halcon-WorkSpaces/Test/Image/test14.png')
  3. rgb1_to_gray (Image, GrayImage)
  4. *获取旋转的矩形
  5. threshold (GrayImage, Regions, 0, 0)
  6. *计算区域斜率
  7. orientation_region (Regions, Phi)
  8. *获取没有旋转的矩形
  9. threshold (GrayImage, Regions1, 100, 140)
  10. area_center (Regions1, Area, Row, Column)
  11. *创建变换模型
  12. vector_angle_to_rigid (Row, Column, 0, Row, Column, Phi, HomMat2D)
  13. *区域变换
  14. affine_trans_region (Regions1, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
  15. dev_clear_window ()
  16. dev_display (RegionAffineTrans)
  17. dev_display (Regions)

效果:

(0)

相关推荐