本文介绍了转换简化离散区域边界多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有独立的地图,在这张地图上出现的国家再通过颜色psented $ P $蓝:
国家地区始终是一致的。
现在我想从中提取边界:
所以:
- 在我的国家无序地砖的列表,在这种情况下:(3,3),(4,3),(4,4)...
- 我要提取的边界有序序列,在这种情况下:((2,2),(3,2)),((3,2),(4,2)),....,其中( (X1,Y1),(X2,Y2))表示边界beggining开始在(X1,Y1),并结束在(X2,Y2)
解决方案
- 首先找到右端点在你的矩阵无论多么高。如果你瑶池点相同的x,任意选择。
- 找到这个点的所有边界。
- 如果你有一个点接壤前,去了,否则进入正确的,否则到了底部,否则向左走,去的方向其中,有边境另一点,总是以该顺序。如果遇到点是起点,去步骤7,否则到下一个步骤。
- 存储两个点(主点,遇到点)在路径。
- 现在,遇到的问题是主点。
- 转到步骤2
- 路径中包含你想要什么
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)
解决方案
- Firstly find the rightest point in your matrix no matter how tall. If you finded points with same x, choose arbitrarily.
- Find all borders of this point.
- If you have a point bordering ontop, go for it, else go to theright, else go to the bottom, elsego to the left, go to the directionwhere have border with other point,always in that order. If encounteredpoint is the initial point, go tostep 7, else go to the next step.
- store the two points (principalpoint, encountered point) in yourpath.
- Now the encountered point isprincipal point.
- Go to step 2
- the path contains what you want
这篇关于转换简化离散区域边界多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!