halcon图像变形-ROI区域旋转

关键算子:

           orientation_region

           vector_angle_to_rigid

           affine_trans_region

 

测试图片:

halcon图像变形-ROI区域旋转

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. *获取没有旋转的矩形

  10. threshold (GrayImage, Regions1, 100, 140)

  11. area_center (Regions1, Area, Row, Column)

  12. *创建变换模型

  13. vector_angle_to_rigid (Row, Column, 0, Row, Column, Phi, HomMat2D)

  14. *区域变换

  15. affine_trans_region (Regions1, RegionAffineTrans, HomMat2D, 'nearest_neighbor')

  16. dev_clear_window ()

  17. dev_display (RegionAffineTrans)

  18. dev_display (Regions)

效果:

halcon图像变形-ROI区域旋转