suppose that I have discrete map, on this map appears country represented by color blue:
country area is always coherent.
Now I开发者_JAVA百科 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
精彩评论