If the image is a GIF (or similar), you have large areas a single colour.
To find where these areas end, an edge detector is the logical choice.
In DSP terms, look at high pass filters to detect changes when you move between areas.
Note: jpeg and other picture formats can have areas where colour slowly changes. In this case, the edge between colours is not ...