rectangle2


* This example program demonstrates the use of union_collinear_contours_xld for connecting
* collinear line segments. This is the new and recommended operator for this task.
* In addition, the program shows how to use the old operator union_straight_contours_xld for
* connecting contours that are not collinear but have neighboring end points.

dev_close_window ()
read_image (Image, 'pads')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_set_colored (12)
dev_set_draw ('margin')
dev_display (Image)

* Remove border

Border := 35
rectangle1_domain (Image, ImageReduced, Border, Border, 576 - Border, 768 - Border)

* Extract edges in the image and detect straight line segments
* Unify collinear line segments and keep only the long ones

* edges_sub_pix (ImageReduced, Edges, 'lanser2', 0.16, 3, 5)
edges_sub_pix (ImageReduced, Edges, 'canny', 5, 3, 5)
segment_contours_xld (Edges, ContoursSplit, 'lines', 5, 4, 2)
select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 20, Width / 2, -0.5, 0.5)
union_collinear_contours_xld (SelectedContours, UnionContours, 10, 1, 8, 0.4, 'attr_keep')
select_contours_xld (UnionContours, SelectedContours1, 'contour_length', 50, 10000, -0.5, 0.5)

dev_display (Image)
dev_display (SelectedContours1)
stop ()

* Further processing (1): connect neighboring contours and get the surrounding box

union_adjacent_contours_xld (SelectedContours1, UnionContours1, 20, 1, 'attr_keep')
smallest_rectangle2_xld (UnionContours1, Row, Column, Phi, Length1, Length2)
gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2)
stop ()


* Further processing (2): fit lines into the collinear contours

dev_display (Image)
fit_line_contour_xld (SelectedContours1, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
for i := 0 to |RowBegin| - 1 by 1
  gen_contour_polygon_xld (Contour, [RowBegin[i],RowEnd[i]], [ColBegin[i],ColEnd[i]])
  dev_display (Contour)
endfor

相关推荐

  1. rectangle2

    2024-03-30 09:46:02       16 阅读
  2. AtCoder_ABC130_Rectangle Cutting

    2024-03-30 09:46:02       13 阅读
  3. LeetCode85. Maximal Rectangle——单调栈

    2024-03-30 09:46:02       27 阅读
  4. dlib中rectangle与opencv的rect的区别

    2024-03-30 09:46:02       15 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-30 09:46:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-30 09:46:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-30 09:46:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-30 09:46:02       20 阅读

热门阅读

  1. UE4 quest3平台网络不稳定问题排查及解决

    2024-03-30 09:46:02       28 阅读
  2. vscode插件

    2024-03-30 09:46:02       19 阅读
  3. Python数据库编程全指南SQLite和MySQL实践

    2024-03-30 09:46:02       19 阅读
  4. 【统计】什么事 R 方

    2024-03-30 09:46:02       20 阅读
  5. 机器学习概念、步骤、分类和实践

    2024-03-30 09:46:02       18 阅读
  6. openGauss JDBC客户端负载均衡与读写分离

    2024-03-30 09:46:02       20 阅读