필터 지우기
필터 지우기

How to remove unwanted tiny objects (blobs) in colored segmented image?

조회 수: 8 (최근 30일)
Nusrat Jahan
Nusrat Jahan 2021년 1월 13일
답변: BC 2021년 2월 28일
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.

답변 (1개)

BC
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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by