title: How do I split a shape with conected pixels in to two parts in a binary image
body: <p>My goal is to draw a rectangle border around the face by removing the neck area connected to the whole face area. All positive values here represent skin color pixels.  Here I have so far filtered out the binary image using OpenCV and python. Code so far <a href="https://github.com/melkorCBA/palm_and_face_regions_detection/blob/master/src/skinId.py" rel="nofollow noreferrer">skinid.py</a></p>
  
  <p>Below is the test image.</p>
  
  <p><a href="https://i.stack.imgur.com/GJLNS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GJLNS.png" alt="enter image description here"></a></p>
  
  <p>Noise removals have also been applied to this binary image</p>
  
  <p><a href="https://i.stack.imgur.com/36arA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/36arA.png" alt="enter image description here"></a></p>
  
  <p>Up to this point, I followed this paper <a href="https://ieeexplore.ieee.org/document/767122" rel="nofollow noreferrer">Face segmentation using skin-color map in videophone applications</a>. And for the most of it, I used custom functions rather than using built-in OpenCV functions because I kind of wanted to do it from scratch. (although some erosion, opening, closing were used to tune it up)</p>
  
  <p>I want to know a way to split the neck from the whole face area and remove it like this, </p>
  
  <p><a href="https://i.stack.imgur.com/9XKKD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9XKKD.png" alt="enter image description here"></a></p>
  
  <p>as I am quite new to the whole image processing area.</p>