title: Python - cv2 find Contours
body: <p>I would like to find all the big elements in the document, but I do not know how to control the size (the document is downloaded from the Internet :))</p>
  <p>I have a document</p>
  <p><a href="https://i.stack.imgur.com/F74Yq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F74Yq.png" alt="enter image description here" /></a></p>
  <p>And I wrote a simple code</p>
  <pre><code>import cv2
  import pytesseract
  
  image = cv2.imread('2.png')
  
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  blur = cv2.GaussianBlur(gray, (7, 7), 0)
  thresh = cv2.threshold(
      blur, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
  
  kernal = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 50))
  dilate = cv2.dilate(thresh, kernal, iterations=1)
  
  cv2.imwrite('1_dilated.png', dilate)
  
  cnts = cv2.findContours(dilate, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  
  cnts = cnts[0] if len(cnts) == 2 else cnts[1]
  
  cnts = sorted(cnts, key=lambda x: cv2.boundingRect(x)[1])
  
  for c in cnts:
      x, y, w, h = cv2.boundingRect(c)
      if h &gt; 100 and w &gt; 100:
          roi = image[y:y+h, x:x+w]
          cv2.rectangle(image, (x, y), (x+w, y+h), (36, 255, 12), 2)
          # ocr = pytesseract.image_to_string(roi)
          # print(ocr)
  cv2.imwrite('1_boxes4.png', image)
  </code></pre>
  <p>But only detects it</p>
  <p><a href="https://i.stack.imgur.com/wrGIO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wrGIO.png" alt="enter image description here" /></a></p>
  <p>And I would like this</p>
  <p><a href="https://i.stack.imgur.com/vQlbo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vQlbo.png" alt="enter image description here" /></a></p>
  <p>How to control the size of the detected area ?</p>
  <p>Thank you very much for all your comments</p>