title: How can I extract internal contours (holes) with python opencv?
body: <p>is there an easy and direct way to extract the internal contours (holes) from an image using opencv 3.1 python ?</p>
  
  <p>I know that I can use "area" as a condition. However, if I change the image resolution, the "areas" are not the same.</p>
  
  <p>For instance, with this image:
  <a href="https://i.stack.imgur.com/jN3ye.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jN3ye.jpg" alt="enter image description here"></a>
  How can I extract the internal holes?</p>
  
  <pre><code>_, contours, hier_ = cv2.findContours(img,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE)
  areas = [cv2.contourArea(c) for c in millCnts]
  max_area = np.max(areas)
  Mask = np.ones(img.shape[:2], dtype="uint8") * 255
  
     # I can do something like this (currently not working, just to show an example)
  for c in contours:
      if(( cv2.contourArea(c) &gt; 8) and (cv2.contourArea(c)&lt; 100000)):
          cv2.drawContours(Mask ,[c],-1,0,1)
  </code></pre>