title: Pytesseract - OCR on image with text in different colors
body: <p>Pytesseract is unable to extract text when texts are present in different colors . I tried using opencv to invert the image but it doesn't work for dark text colors. </p>
  
  <p>The image:
  <img src="https://i.stack.imgur.com/RH5WY.png" alt="see attached image"></p>
  
  <pre><code>import cv2
  import pytesseract
  
  from PIL import Image
  
  
  def text(image):
      image = cv2.resize(image, (0, 0), fx=7, fy=7)
      gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
      cv2.imwrite("gray.png", gray)
  
      blur = cv2.GaussianBlur(gray, (3, 3), 0)
      cv2.imwrite("gray_blur.png", blur)
  
      thresh = cv2.threshold(blur, 127, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
      cv2.imwrite("thresh.png", thresh)
  
      kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
      opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations=1)
      cv2.imwrite("opening.png", opening)
  
      invert = 255 - opening
      cv2.imwrite("invert.png", invert)
  
      data = pytesseract.image_to_string(invert, lang="eng", config="--psm 7")
      return data
  
  </code></pre>
  
  <p>Is there a way to extract both the texts from the given image: DEADLINE(red) and WHITE HOUSE(white) </p>