Background removal in matlab
9 views (last 30 days)
Show older comments
Hi people.please help me with the following question: "using an input colour image and the provided ROI mask, remove the background from the image. Retain only the approximate ROI. treat the mask as ground truth. The ROI mask is only an approximation and not meant to be taken as being exact.
1 Comment
Image Analyst
on 12 Dec 2021
Please tell us what you mean by "remove the background". You in general cannot remove pixels from an image, though you can set them to some color, like black or white. For example if you had a donut, you can make the background black or white, and you could crop out a rectangular sub-image of the bounding box of the donut, but you can't have the center of the donut or the pixels outside of it be "removed" or "missing" since arrays cannot have missing elements. You can set those locations to some certain color, or even NaN or 0 or inf or whatever but you can't just get rid of them.
% Mask the image using bsxfun() function to multiply the mask by each channel individually. Works for gray scale as well as RGB Color images.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
Answers (1)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!