MATLAB Answers

remove unwanted black pixels from binary image

3 views (last 30 days)
Abhinav Singh
Abhinav Singh on 24 Feb 2020
Commented: Adam Danz on 14 May 2020
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 Comments

Show 2 older comments
Guillaume
Guillaume on 26 Feb 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.
Adam Danz
Adam Danz on 14 May 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.

Sign in to comment.

Answers (1)

Subhadeep Koley
Subhadeep Koley on 24 Feb 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);

  0 Comments

Sign in to comment.


Translated by