# Fill a Circle in an Image

Let's suppose I have something like this (the image resulting from this):

ColorNegate[Rasterize[Graphics[Circle[{100, 100}, 50]]]]


Now, what I want to do is fill the inside of the circle (in the image, not transforming Circle->Disk :) ) with White (the color of the circle).

Ideas?

• Binarize@FillingTransform@ ColorNegate[Rasterize[Graphics[Circle[{100, 100}, 50]]]] works for your specific case, though without the binarize the color is different to the edge – dr.blochwave Sep 25 '15 at 14:54
• Also see here: mathematica.stackexchange.com/questions/7781/… – dr.blochwave Sep 25 '15 at 14:58
• Oh... Of course it's FillingTransform. I didn't know about the Binarize. Thank you. If you want to create an answer, and explain maybe better the Binarize part, I'll accept it. – mgm Sep 25 '15 at 14:59
• there you are, hopefully a better explanation of the binarization... – dr.blochwave Sep 25 '15 at 15:10

FillingTransform is what you're after:

img = FillingTransform@ColorNegate[Rasterize[Graphics[Circle[{100, 100}, 50]]]]


But this gives a gray fill because your image wasn't binary to begin with. Easy to fix, e.g. with a subsequent Binarize:

Binarize@img


Alternatively, ColorReplace[] might provide a more general solution.

ColorReplace[img, Gray -> White]