I\'m trying to prepare images for OCR, and so far here is what I\'ve done using info from Extracting text OpenCV
From the resulting image I use the contours that hav
I've tried to maximize the distance between the minimum and the maximum color of one channel and then inverted the colors. (See Code)
img1 = cv2.imread('img.png')
img_reverted = img1.copy()
for i in range(3):
tmp = (img1[:, :, i] - img1[:, :, i].min()) / img1[:, :, i].max()
tmp = tmp * 255
tmp = -1 * tmp + 255
img_reverted[:, :, i] = tmp.astype('uint8');
The results are quite good. (See images)
Original image:
Reverted image: