title: How to extract words from left to right in an image with OpenCV Pytesseract?
body: <p>I am working on a contract sheet with OpenCV and pytesseract. I want to extract words from this image</p>
  <p><img src="https://i.stack.imgur.com/rtrjB.jpg" alt="This image report-image" /></p>
  <p>I am trying with getStructureElement but my code jumps on the next line in the center of the image. I'm trying to extract words from the left side of image and after extracting string from all left then move to right side of image.</p>
  <p>The code is:</p>
  <pre><code>import cv2, import pytesseract, from PIL import Image
  
  image = cv2.imread(&quot;report_name-1.jpg&quot;)
  
  #preprocessing 
  
  gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) # grayscale
  
  thresh = cv2.threshold(gray,150,255,cv2.THRESH_BINARY_INV) # threshold
  
  kernel = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
  
  dilated = cv2.erode(thresh,kernel,iterations = 13) # dilate
  
  contours, hierarchy =cv2.findContours(dilated,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE) # get contours
  
  # get rectangle bounding contour
  [x,y,w,h] = cv2.boundingRect(contour)
  # discard areas that are too large
  if h&gt;300 and w&gt;300:
      continue
  
  # discard areas that are too small
  if h&lt;40 or w&lt;40:
      continue
  
  # draw rectangle around contour on original image
  cv2.rectangle(image,(x,y),(x+w,y+h),(255,0,255),2)
  </code></pre>