MATLAB: Superimposing bw mask on a grayscale image

Image Processing Toolbox

I have a bw image which i obtained by modifying a grayscale image. Now i want to use the bw image as a mask on the grayscale image so that all the other parts except for the white part of the mask in the greayscale image vanishes. i have tried multiplying the images but all i get is bw image with some outer noise around the border.

Best Answer

Try this:
grayImage(~mask) = 0;
Related Question