how can I fill an object in binary image?

3 ビュー (過去 30 日間)
nadia
nadia 2016 年 10 月 28 日
回答済み: Image Analyst 2016 年 10 月 28 日
after image segmentation I have a binary mask which has some holes on it and I can not fill them with imfill function. do you have any idea for it. I have a database and each one is different from others and the hole location is different. one of this image attached hear
.
  1 件のコメント
Massimo Zanetti
Massimo Zanetti 2016 年 10 月 28 日
Why you cannot use imfill?

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2016 年 10 月 28 日
The holes aren't really holes but are actually bays at the top and bottom of the image. What you'll have to do to fill those is to draw a line at the top and bottom of the image and call imfill, then erase the lines afterwards.
binaryImage(1,:) = true;
binaryImage(end,:) = true;
binaryImage = imfill(binaryImage, 'holes');
binaryImage(1,:) = false;
binaryImage(end,:) = false;

Community Treasure Hunt

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

Start Hunting!

Translated by