import cv2
def convert_black_white(path):
img = cv2.imread(path)
# Rescaling
# img = cv2.resize(img, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
grayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
(thresh, blackAndWhiteImage) = cv2.threshold(grayImage, 128, 155, cv2.THRESH_BINARY)
cv2.imwrite(path, grayImage)
cv2.imwrite('/tmp/' + 'changed4.jpg', grayImage)
cv2.imshow("Gray image", grayImage)
cv2.waitKey(0)
cv2.destroyAllWindows()
convert_black_white("test.jpg")
This is my code and I attach input. What I want to do is to remove the SAMPLE background and only get the text with it. Does anyone have any idea?