how to do masking with the help of binary image?
5 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a binary image and using that binary image I wish to do masking.
Here is the binary image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145951/image.jpeg)
Using this binary image I want to mask to the original Image.
Here is the original Image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145952/image.jpeg)
I want the output as :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145953/image.jpeg)
So, the output image should have the binary image portion and the remaining should be black("0").
Can you suggest me the code to do this.
Thanks...
0 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2014-11-3
Here's a way that Sean recommends:
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, class(rgbImage)));
It works for grayscale images too. I also attach some full demos, if you're interested.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!