MATLAB: How i can remove the white colour in binary image ? please help me

Image Processing Toolboximage segmentation

my objective is to remove the stalk from palm oil fruit , i already convert the image into binary image , but then the stalk become in white colour, so i need to remove those white colour and convert back to RGB. ho i can remove those white colour ? please help me

Best Answer

Mask the RGB image
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(~mask, 'like', rgbImage));
Note that I used ~ to invert the mask so we will keep anything that is black, and remove (blacken) anything that is white in your mask from the RGB image.
Related Question