How to remove unwanted tiny objects (blobs) in colored segmented image?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
BC
2021-2-28
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!