remove unwanted black pixels from binary image

조회 수: 1 (최근 30일)
Abhinav Singh
Abhinav Singh 2020년 2월 24일
댓글: Adam Danz 2020년 5월 14일
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
Rena Berman
Rena Berman 2020년 5월 14일
(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일
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);

Community Treasure Hunt

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

Start Hunting!

Translated by