Filling objects that share a border

조회 수: 7 (최근 30일)
alexius
alexius 2013년 9월 4일
Hi,
I have a question about filling in objects that share a border with the perimeter of an image.
Consider a case such as the one shown at: http://i43.tinypic.com/2nq9ua.jpg. If I run the imfill function to fill in the holes, I don’t get the five objects that touch the border of the image filled (I have pointed out the specific areas I am talking about, in this image: http://i41.tinypic.com/5afeo4.jpg).
Is there any strategy I could follow to fill holes in those areas that are outlined using the arrows?
Thanks in advance!

채택된 답변

Image Analyst
Image Analyst 2013년 9월 4일
편집: Image Analyst 2013년 9월 5일
  1. Binarize and Invert the image: binaryImage = grayImage <128
  2. Call imfill(binaryImage, 'holes')
  3. call regionprops(binaryImage, 'BoundingBox') asking for bounding box
  4. Look at the 4 sides of all the bounding boxes looking for any objects that share any bounding box side coordinate.
Give it a shot.
  댓글 수: 3
alexius
alexius 2013년 9월 5일
thank you Image Analyst for the answer. I've tried the code, and get error..
Error in imfill (line 132)
mask = padarray(mask, ones(1,ndims(mask)), -Inf, 'both');
Error in padarray (line 51)
binaryImage = imfill(binaryImage, 'holes');
can you help me, I’m quite new to IPT.
alexius
alexius 2013년 9월 5일
I'm sorry. I forgot to change the folder and filename. Now the code works. Thank you Image Analyst. :D

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Anand
Anand 2013년 9월 6일
Steve Eddins just posted about this. Here's an alternative approach:

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by