#this script is for image preprocess. ICM is time confused to do #hsv and rgb stretching, so just replace with rgb stretching, import cv2 import numpy as np clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8)) def gray_stretching(image): #stretching gray image with single channel. Imax=np.max(image) Imin=np.min(image) MAX=255 MIN=0 image=(image - Imin) / (Imax - Imin)* (MAX - MIN) + MIN #return image.astype('uint8') return image def BGR_stretching(image): #accept a BGR image read from cv2, split channel and do stretch seperately. B,G,R=cv2.split(image) ''' B=gray_stretching(B) G=gray_stretching(G) R=gray_stretching(R) ''' B=clahe.apply(B) G=clahe.apply(G) R=clahe.apply(R) image=cv2.merge([B,G,R]).astype('uint8') return image