Color a Map by Country
Color individual countries in the image of a map. This example appears in Stephen Wolfram’s video Introduction to the Wolfram Language.
how it works
MorphologicalComponents gives an array in which each pixel of an image is replaced by an integer index representing the connected foreground image component in which the pixel lies. Colorize generates an image from the array, using colors for positive integers and black for non-positive integers.