remove unwanted black pixels from binary image

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

Can you provide the original image and code you used to get your binary image?
Adam Danz
Adam Danz 2020년 2월 26일
In response to the comment posted as a flag: I would like to delete this question.
If you're seeking free help and consultation in this forum, and you benefit from someone volunteering their time to help you, removing the content of the question is disprespectful and selfish. The majority of help that others find in this forum is from questions and answers that have already been asked and ansered. When you remove the content of your quesiton, the forum becomes less useful.
If an answer below helped you, thank the contributor by accepting it and|or voting up the answer. If it wasn't helpful and you found a better solution, provide it. If you'd rather get private consultation, there are plenty of fee-for-service sites out there.
Your question can't be deleted.
Guillaume
Guillaume 2020년 2월 26일
To add to what Adam said, note that editing your question away is not going to help. Mathworks will restore it to its original state.
(Answers Dev) Restored edit
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일

0 개 추천

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);

질문:

2020년 2월 24일

댓글:

2020년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by