title: how to change area of contours formation in opencv (threshold)
body: <p>I am trying to build OCR for extracting text from Image, I am using contours in forming boundaries of text characters,</p>
  
  <p>After several trials of changing cv2.threshold i got best fit of contours in forming boundaries of text characters.</p>
  
  <pre><code>#files = os.listdir(r'letters/harry.jpeg',0)
  file = r'/home/naga/Documents/Naga/Machine Learning/Data_extract/letters/Harry/Harry Potter and the Sorcerer s Stone-page-006.jpg'
  im1 = cv2.imread(file,0)
  im = cv2.imread(file)
  
  # ret,thresh1 = cv2.threshold(im1,180,278,cv2.THRESH_BINARY)
  # _,contours, hierarchy = cv2.findContours(thresh1,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
  
  ret,thresh1 = cv2.threshold(im1,180,278,cv2.THRESH_BINARY)
  kernel = np.ones((5,5),np.uint8)
  dilated = cv2.dilate(im1,kernel,iterations = 1)
  _,contours, hierarchy = cv2.findContours(dilated,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
  
  for cnt in contours:
      x,y,w,h = cv2.boundingRect(cnt)
      #bound the images
      cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),1)
  
  cv2.namedWindow('BindingBox', cv2.WINDOW_NORMAL)
  cv2.imwrite('output2/BindingBox4.jpg',im)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ODwWA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ODwWA.jpg" alt="Contours on text with Opencv"></a></p>
  
  <p>Now i would like to create contours on words. I need parent contours on each word. what are the attributes to change in Open cv.</p>
  
  <p>I am new to opencv, I followed through <a href="https://docs.opencv.org/3.4.0/d7/d4d/tutorial_py_thresholding.html" rel="nofollow noreferrer">cv2 threshold</a> but could'nt understand to apply it on. plz give your inputs in forming contours on words.</p>
  
  <p><a href="https://i.stack.imgur.com/k089v.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k089v.jpg" alt="original pic"></a></p>