title: Fill the elements close to the region of the image
body: <p>I have black and white image, which has some white elements touching the border of the image<a href="https://i.stack.imgur.com/OQ5wH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQ5wH.png" alt="enter image description here"></a>.</p>
  
  <p>I am trying to fill in these white parts (on this image there is only one part, but there can be multiple) with a black color. My only idea is to iterate over the pixels on the border of the image and whenever I see a white pixel run the algorithm which recursively fills all the white pixels of the surrounding white pixels.</p>
  
  <p>Although this will clearly produce the result I want, I hope that there is an easier way to achieve this with numpy/scipy/scikit-image.</p>
  
  <p>While searching through the SO, the only related question I have found was <a href="https://stackoverflow.com/questions/22310489/filling-holes-in-objects-that-touch-the-border-of-an-image">this</a>. The question sounds similar to what I want, but actually solves another problem. Is there any hope to find an easy solution for me?</p>