title: Tricky filling holes in an image
body: <p>I need to fill holes in images using python.
  This is the image with objects that I managed to get - they are really edges of objects I want, so I need to fill them.
  <a href="https://i.stack.imgur.com/IpauJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IpauJ.png" alt="enter image description here"></a></p>
  
  <p>It seemed very straightforward using <code>ndimage.binary_fill_holes(A)</code>, but the problem is that it produces this (manually filled with red colour):</p>
  
  <p><a href="https://i.stack.imgur.com/koNd2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/koNd2.png" alt="enter image description here"></a></p>
  
  <p>But I need this:</p>
  
  <p><a href="https://i.stack.imgur.com/kO9x0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kO9x0.png" alt="enter image description here"></a></p>
  
  <p>Any way this can be solved?</p>
  
  <p>This is the first image without the axes if you want to give it a try: <a href="https://i.stack.imgur.com/9JiQB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9JiQB.png" alt="enter image description here"></a></p>