Mask image in Matlab
3 views (last 30 days)
I am using Matlab for image analysis. However, after I binarized the image, I conducted a complement of a binary image, resulting in inverted black and white. I am wondering how you could mask the internal pixels in black while the background still remains unchanged (for Fig 4b and Fig 4c).
I am looking forward to hearing from you soon.
millercommamatt on 4 Oct 2022
I think imclose will do what you want.
Image Analyst on 4 Oct 2022
You can call imfill on your binary image to fill your closed blobs. So an "O" will get filled, but a blob with a broken perimeter like a "C" will not get filled. You have to have your segmented things white first, not black;
mask = ~mask; % Turn black into white, and white into black.
mask = imfill(mask, 'holes');