将简化的离散区域转换为边界多边形 [英] Convert simplified discrete area to borders polygon

查看:182
本文介绍了将简化的离散区域转换为边界多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有离散地图,在这张地图上出现的国家以蓝色表示:





国家/地区总是一致的。



现在我想从中提取边框:





所以:




  • 我有一个无序的瓷砖列表国家,在这种情况下:(3,3),(4,3),(4,4)...

  • 我想提取有序的边界序列,在这种情况下: ((2,2),(3,2)),((3,2),(4,2)),....其中((x1,y1),(x2,y2))表示开始边框从(x1,y1)开始,以(x2,y2)结尾。


解决方案


  1. 首先找到矩阵中最右边的点,无论多高。如果您找到相同x的点,请任意选择。

  2. 查找此点的所有边框。

  3. 如果您有一个点接近
    顶部,去吧,否则去
    右边,否则去底部,否则
    去左边,去方向
    与其他点有边框
    总是按照这个顺序。如果遇到
    点是初始点,请转到
    第7步,否则转到下一步。

  4. 存储两点(主体

  5. 现在遇到的点是
    主要点。

  6. 转到步骤2

  7. 路径包含您想要的


suppose that I have discrete map, on this map appears country represented by color blue:

country area is always coherent.

Now I want to extract borders from it:

So:

  • I have a list of unordered tiles of country, in this case: (3,3), (4,3), (4,4)...
  • I want to extract ordered sequence of borders, in this case: ((2,2),(3,2)), ((3,2),(4,2)),.... where ((x1,y1),(x2,y2)) means that beggining of border starts in (x1,y1) and ends in (x2,y2)

解决方案

  1. Firstly find the rightest point in your matrix no matter how tall. If you finded points with same x, choose arbitrarily.
  2. Find all borders of this point.
  3. If you have a point bordering on top, go for it, else go to the right, else go to the bottom, else go to the left, go to the direction where have border with other point, always in that order. If encountered point is the initial point, go to step 7, else go to the next step.
  4. store the two points (principal point, encountered point) in your path.
  5. Now the encountered point is principal point.
  6. Go to step 2
  7. the path contains what you want

这篇关于将简化的离散区域转换为边界多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆