转换简化离散区域边界多边形多边形、边界、区域

2023-09-11 06:48:16 作者:靠天靠地不如靠自己.

假设我有独立的地图,在这张地图上出现的国家再通过颜色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:

一家商店将某种商品按成本价提高50 后.标价为450元.又以8折出售.则售出这件商品可获利润 元. 题目和参考答案 青夏教育精英家教网

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 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. store the two points (principal point, encountered point) in your path. Now the encountered point is principal point. Go to step 2 the path contains what you want