MATLAB: How to fill color in the specified area

colorimage processingImage Processing Toolbox

How to fill color in the specified area?

Best Answer

You can use imfill() if you have a binary image, or if the binary image is a mask, then for a black and white image, you can do
grayImage(binaryImage) = fillColor; % Whatever this might be, say 42 or 123.
If you have a color image, you can do
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));