# How to do color-fill in images in Mathematica?

Color fill, the ability to apply a desired color to an enclosed area, is one of the basic functions provided by most graphic applications. Is there a similar function provided in Mathematica? For example, how to obtain a red, green, blue and yellow horses silhouette from the picture below in Mathematica?

im = Import["http://i.stack.imgur.com/ZDeYq.jpg"]
ReplacePixelValue[im, {924, 221} -> Blue]


ReplacePixelValue seems only work on one pixel only.

Colorize seems provide no controls on obtaining a specific color.

ColorReplace seems only work on a bundle of the same color all together .

im = Binarize@Import["http://i.stack.imgur.com/ZDeYq.jpg"];

• Thank you so much. It seems there is a strange behaviour behind MorphologicalComponents, So I raised another question about it. – Putterboy Sep 11 '14 at 7:57
• @Putterboy Not at all: MorphologicalComponents[image,t] treats values above t as foreground. – Dr. belisarius Sep 12 '14 at 19:16