remove unwanted black pixels from binary image

4 次查看(过去 30 天)
I have a binary image of a zebra fish. im trying to segment the fish but im getting the unwanted black pixels from the image. Im attaching two images- one with unwanted black pixels and one without unwanted black pixels.
  5 个评论
Adam Danz
Adam Danz 2020-5-14
Copy of question
I have a binary image of a zebra fish. im trying to segment the fish but im getting the unwanted black pixels from the image. Im attaching two images- one with unwanted black pixels and one without unwanted black pixels.

请先登录,再进行评论。

回答(1 个)

Subhadeep Koley
Subhadeep Koley 2020-2-24
It is difficult to fill the binary image exactly as you want but twaeking the various parameters of the function bwmorph we can go pretty close. Perform the following operations on your binary image.
b = bwmorph(b, 'close', Inf);
b = imfill(b,'holes');
se = strel('line', 8, 30);
b = imerode(b, se);
b = bwmorph(b, 'majority', Inf);
figure; imshow(b);

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by