When enlarging or shrinking with the cv2.resize function, 16-bit grayscale images are increased to 24 bits. Is there a way to resize them without changing the depth?
img=cv2.imread("16bitgray.tiff")
img512 = cv2.resize(img, (512,512), interpolation=cv2.INTER_NEAREST)
CodePudding user response:
If you read a 16-bit greyscale TIFF with:
img=cv2.imread("16bitgray.tiff")
you'll get an RGB888 TIFF because that is the default. You need:
img=cv2.imread("16bitgray.tiff", cv2.IMREAD_UNCHANGED)