问题提出:求下图中楔形缺口到圆心的最短距离。

【涉及知识点讲解】

一、Region特征算子

在图形窗口中用鼠标单击选中某个Region,然后点击菜单栏的“打开特征检测”图标,就可以看到当前Region的所有特征了。

由特征检测页面可知,Region的特征很多,如何知道用什么算子可以获得这些特征呢?

① 鼠标放在特征上悬停

② region_features

二、形态学算子(以下面四个为例)

dilation_circle

erosion_circle

opening_rectangle1

closing_rectangle1

拓展阅读:https://www.cnblogs.com/xh6300/p/6397289.html

三、tuple_concat和tuple_length、tuple_min

tuple叫做元组,类似于C#中的ArrayList。

a := 3

a := [a,4]

tuple_concat (a, 5, Concat)

a := [a,5]

tuple_length (Concat, Length)

len := |a|

tuple_min (a, Min)

minValue := min(a)

https://www.cnblogs.com/xh6300/p/6117688.html

四、完整代码

*方法1:逐次逼近法

dev_set_draw ('margin')

read_image (Image, 'circle.jpg')

threshold (Image, Region, 0, 80)

opening_circle (Region, Region, 3.5)

smallest_circle (Region, Row, Column, Radius)

*Row, Column即是圆心坐标

gen_circle (Circle, Row, Column, Radius)

gen_cross_contour_xld (Cross, Row, Column, 6, 0.785398)

difference (Circle, Region, RegionResult)

*去掉细窄边缘

opening_circle (RegionResult, RegionResult, 3.5)

*求最小外接圆直径

diameter_region (RegionResult, Row1, Column1, Row2, Column2, Diameter)

gap := Radius - Diameter

*设置缺省值

realGap := gap

for i := gap to Radius by 1

gen_circle (Circle1, Row, Column, i)

intersection (Circle1, RegionResult, RegionIntersection)

area_center (RegionIntersection, Area, Row3, Column3)

if (Area > 0)

realGap := i

break

endif

endfor

dev_display (Image)

disp_message (3600,'MinDist1:' + realGap, 'image', Row, Column, 'black', 'true')

*方法2:distance_pr

distance_pr (RegionResult, Row, Column, DistanceMin, DistanceMax)

disp_message (3600,'DistanceMin: ' + DistanceMin, 'image', Row, Column, 'black', 'true')

dev_display (Image)

*方法3:遍历点坐标,求最小距离

get_region_points (RegionResult, Rows, Columns)

Distances := []

for i := 0 to |Rows|-1 by 5

distance_pp (Row, Column, Rows[i], Columns[i], Distance)

Distances := [Distances , Distance]

endfor

tuple_min (Distances, Min)

disp_message (3600,'MinDist1:' + realGap, 'image', Row, Column, 'black', 'true')

disp_message (3600,'DistanceMin: ' + DistanceMin, 'image', Row+20, Column, 'black', 'true')

disp_message (3600,'Min: ' + Min, 'image', Row+40, Column, 'black', 'true')

最新文章

  1. IE11兼容性问题修改
  2. su - root 报su: incorrect password的错误
  3. chmod和fchmod函数 /chown ,fchown,lchown函数
  4. BootStrap2学习日记22---点击展开
  5. crawler
  6. js中将函数传递给另一个函数的解析(非常容易理解)
  7. nfs 搭建
  8. JSON串行化
  9. mysql主从复制-异步复制
  10. Java虚拟机面试重点-------------内存分配和回收策略
  11. 关于 printf scanf getchar
  12. Android布局:宽度适应的横向跟随,防止挤掉重要视图
  13. R语言中的回归诊断-- car包
  14. re:从零开始的数位dp
  15. 康拓展开-排列的hash
  16. python永久添加第三方模块,PYTHONPATH的设置
  17. Notepad++ 删除空白行的方法
  18. Smarty常用函数
  19. ASP.NET AJAX web chat application
  20. requirejs——基础

热门文章

  1. ffmpeg同步
  2. win10下多版本apache(2.2,2.4)+php(5.3.5,5.5.37,5.6.25,7.0.8)注意点
  3. 洛谷 P2054 [AHOI2005]洗牌
  4. Rust笔记
  5. uva-705-深搜
  6. 数学公式 AS3应用
  7. eclipse 和 javaClass
  8. 使用sql获取primary key名称
  9. How to Pronounce the Word THEM
  10. iKcamp|基于Koa2搭建Node.js实战(含视频)☞ 视图Nunjucks