I want to open an image using cv2 in the original bit depth and eventually split the channels for analysis. Using the cv2.IMREAD_ANYDEPTH tag works but changes im.shape. What is happening and how can I avoid this behavior? This is being done in Colab.
import cv2
im = cv2.imread(image.tiff)
print(im.dtype)
print(im.shape)
im = cv2.imread(image.tiff, cv2.IMREAD_ANYDEPTH)
print(im.dtype)
print(im.shape)
The output:
uint8
(957, 641, 3)
uint16
(957, 641)
According to various posts this should not happen. Still not sure why the channels are being lost.
Seems that this issue can be totally avoided using the following different tag.
This preserves the dtype and shape.