import cv2
from PIL import Image
import numpy as np
img = cv2.imread('0.png')
#OpenCV reads into GBR not RBG but everything else even saving uses RBG
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#You can also change to GRAY
#img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#or img = img[:, :, 0]
#Or load as Gray
#img = cv2.imread('0.png', 0)
#Lineart is a bit more difficult
#(thresh, img) = cv2.threshold(img, 128, 255,cv2.THRESH_BINARY|cv2.THRESH_OTSU)
img.shape
img = cv2.resize(img, (512, 512))
img.shape
cv2.imwrite('my.png', img)
#If color: e.g. shape (x, y, 3) otherwise https://pillow.readthedocs.io/en/3.1.x/handbook/concepts.html#concept-modes
img = Image.fromarray(img, 'RGB')
#If gray e.g. shape (x, y)
img = Image.fromarray(img, 'L')
img.save('my.png')
#PIL Image
#import cv2
from PIL import Image
import numpy as np
im = Image.open('0.png')
im = Image.fromarray(img)
b, g, r = im.split() #You can get the colors as images seperately
im = Image.merge("RGB", (r, g, b)) #You can merge images into r,g and b
im.save('chosen_spectrum.jpg')
#Back to cv2
img = np.array(im)
Sketching, can help for text with different lightness
https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/
Images with different light background to the same
https://www.pyimagesearch.com/2014/06/30/super-fast-color-transfer-images/
Other
https://www.pyimagesearch.com/practical-python-opencv/?src=resource-guide-conf
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/