title: How Can I only keep text with specific color from image via opencv and python?
body: <p>I have some invoice image with some text overlapping, which make some trouble for later processing, and what I only is the text in black. some I want to remove the text which is in other colors.</p>
  
  <p>is there any way to achieve this?</p>
  
  <p>the image is attached as example.</p>
  
  <p>I have tried to solve it with opencv, but i still can't solve this:</p>
  
  <pre><code>import numpy as np import cv2
  img = cv2.imread('11.png')
  
  lower = np.array([150,150,150]) 
  
  upper = np.array([200,200,200])
  
  mask = cv2.inRange(img, lower, upper) 
  res = cv2.bitwise_and(img, img, mask=mask) 
  cv2.imwrite('22.png',res)
  </code></pre>
  
  <p>[image with multiple color][1]</p>
  
  <p>[1]: <a href="https://i.stack.imgur.com/nWQrV.pngstrong" rel="nofollow noreferrer">https://i.stack.imgur.com/nWQrV.pngstrong</a> text</p>