MATLAB: How to fill BLACK a region in an image

black fillingfillhole fillingImage Processing Toolboximfill

I have an image (no matter gray or binary). I want to fill several regions (that are selected by the user through interface) in BLACK!
imfill and roifill cannot do this, because they fill in white!
(I think roifill is exactly what I need, but it fills them white not black!)
Does anybody know how I can resolve my problem?

Best Answer

It does matter if they're grayscale or binary. You will probably have to use morphology. For example you might need to erode or dilate your binary image so that you don't fill with white. Or you might be able to use logical indexing. Can you post your image so I can recommend a method?