Here’s my problem – I have a map of the world or some sort of region, like this:

I need to generate a “border points” table for this map of a region in order to generate imagemaps and dynamically highlight certain areas. All of the maps’ regions will have borders of one color to define them (in the example image, white).
So far, I’m thinking of some sort of flood-fill based method – note that speed and efficiency are not that important, as the script is in no way intended to be used in real time.
Is there a better way to do this that I don’t know of? Is my approach fundamentally wrong? Any suggestions would be appreciated!
If the regions are completely isolated one from each other, looking at connected components would do the trick. In Mathematica it looks like:
First create a binary image from the world map:
Then compute the connected components:
Now you may extract properties for each of the components (masks, perimeters, etc.). Here I colorized each regions with a unique color:
To get the border of a given component, one can query for the binary mask of the component and then compute the perimeter.
This gets all the masks:
As an example, get the border, or contour, of one region:
Getting 2D positions for the border is just a matter of extracting the white pixels in the image: