Q:

remove other color/ noise by using opencv

I'm doing research on removing the background noise from the texts, I already knew these texts will have the fixed color, but the noise can be very different.
for example, I want to remove the rest part from the image but only remains the text "Do it now!", my plan is doing the pre-process for this image first, remove the noise, and send the processed image to tesseract to do OCR, see the picture here: 

I'm new to opencv and have some basics knowledge of opencv, could someone point me a direction so I can learn it?
right now, tesseract cannot detect any text from this image
[from PIL import Image
from pytesseract import *

if __name__ =="__main__":
    pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
    print(pytesseract.image_to_string(Image.open('test.png'))) # print nothing here.

A:

you can use hsv mask:
def img_hsv_mask(img):
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)           
    lower_hsv = np.array([0, 0, 150])           
    upper_hsv = np.array([255, 20, 255])         
    mask = cv2.inRange(hsv, lower_hsv, upper_hsv) 
    cv2.imshow("mask", mask)
    cv2.waitKey (0)

out put mask image as this:

now you can use OCR with mask image:
code = pytesseract.image_to_string(mask, lang='eng')
print(code)
>>~ Do itnow

