How can I color only specific blobs in my segmented image?

1 次查看(过去 30 天)
I have a segmented/labeled image. There are some segments that are too big, and I have their blob indices. I would like to color those blobs red while keeping the other blobs white. How can I do that? My current code below keeps the badBlobs, but turns the other blobs black.
Also, I would like the badBlobs to all be red, not with a spectrum like in the hsv colormap. How can I do that?
I am attaching the image that I am using.
And this is the result that I'm getting:
I want all other blobs to be visible as well, but in white.
Thanks.
Edit: wording
badBlobs = [25];
newImage = segmentedImage;
%Keep only blobs that are too big
binaryImage = ismember(newImage, badBlobs);
labeledImage = bwlabel(binaryImage);
%Show bad openings
figure('Name', 'Bad openings', 'numbertitle', 'off');
imshow(labeledImage);
colormap('hsv')

采纳的回答

Image Analyst
Image Analyst 2022-2-16
colorizedImage = imoverlay(segmentedImage, binaryImage, 'r');
  1 个评论
Andrea Labudzki
Andrea Labudzki 2022-2-16
Hi Image Analyst! Thanks for the answer. This worked perfectly! Over the past few months, you've helped me so much with my project. This is my final thesis for my Engineering Bachelors and you've helped me countless times so thank you so so much!! I really appreciate all your answers. :D

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by