【问题标题】:Halcon - extend region where it intersects with another regionHalcon - 扩展与另一个区域相交的区域
【发布时间】:2021-01-29 00:03:00
【问题描述】:

左图是我的起始情况:红色是一个区域,黑色是一个XLD矩形。

权利是我想要达到的。我需要在区域与矩形接触的任何地方,该区域都被 X 像素拉伸。我的方法是绘制一个宽度为“X”的矩形区域,然后将其合并为“union2()”,但我很难找出矩形的 Y 坐标。更好的是,我可以找到交叉点,但我不知道如何找出它是交叉点的“开始”还是“结束”,所以它是矩形的顶部还是底部。我是认为第一个总是开始,然后它们交替出现,但实际上交集在同一像素处返回两个值..

【问题讨论】:

    标签: geometry region halcon


    【解决方案1】:

    这里是演示代码

    dev_close_window ()
    dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
    
    * Creation of a Region
    gen_circle (Circle1, 150, 200, 100.5)
    gen_circle (Circle2, 250, 150, 50.5)
    gen_circle (Circle3, 350, 200, 100.5)
    union2 (Circle1, Circle2, RegionUnion1)
    union2 (Circle3, RegionUnion1, Region)
    
    * Creation of a xld
    gen_rectangle2_contour_xld (Rectangle_xld, 250, 210, 0, 100.5, 205.5)
    
    * Convert xld to region
    gen_region_contour_xld (Rectangle_xld, Rectangle_region, 'margin')
    
    * intersection
    intersection (Region, Rectangle_region, RegionIntersection)
    
    * stretch RegionIntersection
    Stretch := 30
    area_center (RegionIntersection, AreaRegionIntersection, RowRegionIntersection, ColumnRegionIntersection)
    
    hom_mat2d_identity (HomMat2DIdentity)
    hom_mat2d_scale (HomMat2DIdentity, 1, -Stretch, RowRegionIntersection, ColumnRegionIntersection, HomMat2DScale)
    affine_trans_region (RegionIntersection, RegionIntersectionStretched, HomMat2DScale, 'nearest_neighbor')
    
    union2 (Region, RegionIntersectionStretched, FinalRegion)
    

    输入

    输出

    【讨论】:

      猜你喜欢
      • 2021-01-29
      • 2020-12-13
      • 2020-10-28
      • 2021-11-08
      • 2020-12-23
      • 1970-01-01
      • 2020-03-30
      • 2022-10-17
      • 1970-01-01
      相关资源
      最近更新 更多