geometry - Halcon - 扩展与另一个区域相交的区域
问题描述
左图是我的起始情况:红色是一个区域,黑色是一个 XLD 矩形。
权利是我想要达到的。我需要在区域与矩形接触的任何地方,该区域都被 X 像素拉伸。我的方法是绘制一个宽度为“X”的矩形区域,然后将其合并为“union2()”,但我很难找出矩形的 Y 坐标。更好的是,我可以找到交叉点,但我不知道如何找出它是交叉点的“开始”还是“结束”,所以它是矩形的顶部还是底部。我是认为第一个总是开始,然后它们交替出现,但实际上交集在同一个像素处返回两个值。
解决方案
这里有一个演示代码
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)
输入
输出
推荐阅读
- dynamic-linking - 对同一个可执行文件使用 2 个不同的共享库
- mysql - SQL两表查询
- powershell - Powershell:只知道实际文件名的一部分来测试路径
- python - 如何在 Seaborn 中旋转计数图?
- react-native - 在 React Native 中如何浮动:左右浮动?
- winapi - 在 64 位架构的内存中创建对话框模板
- python - 神经网络错配中的输入和输出形状
- python - DAG 上的文件列表未更新
- docker - 无法在 docker 上使用火炬模型启动 gunicorn flask 应用程序
- python - 如何在单击按钮时更改烧瓶 babel 的语言?