using the attached color image and ROI mask and how can I remove the background from the image and retain only the approximate ROI.
32 views (last 30 days)
More Answers (1)
Image Analyst on 12 Dec 2021
Edited: Image Analyst on 12 Dec 2021
Looks like you've accepted Matt's answer so you probably don't need this but
rgbImage = imread('ROI.png');
mask = logical(imread('mask.png'));
% Make mask 3-D
mask = cat(3, mask, mask, mask);
rgbImage(~mask) = 0;
I haven't tested it but that will probably work. If it's not your homework, try that.
If it's your homework then you may not be able to use imread(), cat(), logical(), imshow(), etc. so see this link:
and of course you wouldn't be able to use our code either - that would be even worse than using built-in functions and you could face disciplinary action.