MATLAB: How to do masking of color image

HI,
How to do masking for the color image;
thanks

Best Answer

Here's how to mask an RGB image with a logical mask image (courtesy of Sean de Wolski):
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, class(rgbImage)));