How to remove unwanted tiny objects (blobs) in colored segmented image?
3 views (last 30 days)
Show older comments
I have a color image obtained after applying segmentation operation, but there are some tiny unwanted bolbs which needed to remove. Most of the codes that I seen are only applied for grayscale images, not for colored image. It will be highly appreciated if anybody provide me the code for removing unwanted tiny objects (blobs) for colored segmented image please.
0 Comments
Answers (1)
BC
on 28 Feb 2021
You can convert the image to grayscale, and then once you've made adjustments to it, you can overlay the mask on top of the original colour image.
image = imread("sample.jpg"); % read image
grayImage = rgb2gray(image); % convert to grayscale
imageOpen = bwareaopen(grayImage,6000); % remove blobs smaller than 6000 pixels. Adjust the number to change this.
imageOverlay = imoverlay(image,~imageOpen,"k"); % overlay the original image with the mask, fill with black (k).
imshowpair(image,imageOverlay,"montage") % display image side by side to compare
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!