remove unwanted black pixels from binary image
Mostrar comentarios más antiguos
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 comentarios
Turlough Hughes
el 24 de Feb. de 2020
Can you provide the original image and code you used to get your binary image?
Adam Danz
el 26 de Feb. de 2020
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
el 26 de Feb. de 2020
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.
Rena Berman
el 14 de Mayo de 2020
(Answers Dev) Restored edit
Adam Danz
el 14 de Mayo de 2020
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.

Respuestas (1)
Subhadeep Koley
el 24 de Feb. de 2020
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);
Categorías
Más información sobre Image Segmentation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!