I am trying to use a neural net to colorize images. I want to do it in the lab colorspace. I can not really find a straight answer as to what the ranges on the channels are. I know I could just load and image and use np.min and np.max after doing the conversion, however, I don't know if my image spans the full range of colors. I need to normalize each channel between 0 and 1.0. I don't want to divide by the max and subtract the min since this needs to be consistent between images.
def preprocessImage(img):
s = min(H / img.shape[0], W / img.shape[1])
if s < 1:
img = cv2.resize(img, (0, 0), fx = s, fy = s, interpolation = cv2.INTER_CUBIC)
img = cv2.cvtColor(np.float32(img) / 255.0, cv2.COLOR_BGR2LAB)
print(img)
plt.imshow(img)
plt.show()
Aucun commentaire:
Enregistrer un commentaire