Thanks for your reply.

My idea was similar. I was searching for a "edge finding" algorithm. But the real picture is huge and takes too much time.

This is a Map projection software. Before generating the map, I have calculated complete list of x,y and color value of pixels and loaded into memory (and saved into a database for future use).

I'll try your idea and let you know how it goes.

Thanks.