设置首页收藏本站
开启左侧

如何剪裁XLD

[复制链接]
完美世界 发表于 2019-1-8 14:16:56 | 显示全部楼层 |阅读模式
我用的是一个Rectangle2建立的Roi,然后根据region生成的XLD
但是生成XLD的时候他会把边缘当成线,如何把这个边缘去掉呢,我发现halcon中有Clip_xxxx, crop_xxx算子,但是这些算子的剪裁区域都只是rectangle1类型,不支持rectangle2,像我这种情况如何才能把边上的直线剪裁掉呢

  1. read_image (Image2, 'C:/Users/Administrator/Desktop/ImageSaved/2.jpg')
  2. dev_close_window()
  3. dev_open_window_fit_image(Image2, 0, 0, -1, -1, WindowHandle)
  4. dev_display(Image2)
  5. draw_rectangle2(WindowHandle, Row, Column, Phi, Length1, Length2)
  6. dev_set_draw('margin')
  7. gen_rectangle2(Rectangle, Row, Column, Phi, Length1, Length2)

  8. reduce_domain(Image2, Rectangle, ImageReduced)

  9. threshold (ImageReduced, Regions, 163, 255)

  10. gen_contour_region_xld(Regions, Contours, 'border')
复制代码

如下图
QQ图片20190108141603.png
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| 完美世界 发表于 2019-1-8 14:29:43 | 显示全部楼层
哪位大哥帮忙看下,这个问题一直很困惑,我觉得halcon肯定是有其他办法的,但是我不知道怎么处理
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
glkos 发表于 2019-1-9 18:00:29 | 显示全部楼层
思路是用生成的旋转矩形中心和角度先来旋转轮廓和矩形,然后裁剪完之后,再旋转回去
  1. read_image (Image, 'E:/halcon学习/Learning/ArcLine.png')
  2. dev_close_window ()
  3. dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
  4. dev_display (Image)
  5. threshold (Image, Region, 0, 100)
  6. gen_contour_region_xld (Region, Contours, 'border')
  7. gen_rectangle2 (Rectangle, 119.204, 114.615, rad(27.1565), 66.5368, 62.0099)
  8. hom_mat2d_identity (HomMat2DIdentity)
  9. vector_angle_to_rigid (119.204, 114.615, 0, 119.204, 114.615, rad(-27.1565), HomMat2D)
  10. affine_trans_region (Rectangle, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
  11. affine_trans_contour_xld (Contours, ContoursAffineTrans, HomMat2D)
  12. smallest_rectangle1 (RegionAffineTrans, Row1, Column1, Row2, Column2)
  13. clip_contours_xld (ContoursAffineTrans, ClippedContours1, Row1, Column1, Row2, Column2)
  14. hom_mat2d_identity (HomMat2DIdentity)
  15. vector_angle_to_rigid (119.204, 114.615, 0, 119.204, 114.615, rad(27.1565), HomMat2D)
  16. affine_trans_contour_xld (ClippedContours1, ContoursAffineTrans1, HomMat2D)
复制代码


ArcLine.png
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表