Convert simplified discrete area to borders polygo

2019-07-27 09:39发布

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

country without borders

country area is always coherent.

Now I want to extract borders from it:

country with borders

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条回答
时光不老,我们不散
2楼-- · 2019-07-27 10:24
  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
查看更多
登录 后发表回答