I want to read pgm image in python. I use cv2.imread('a.pgm') but it returns wrong results. In Matlab, I use imread and get the right result which is a single channel 16-bit image. But cv2.imread in python returns a 3-channel image and the pixel values are also wrong. Why it happens? How should I read the 16-bit pgm images in python? And what libraries?
Thanks in advance.
I got it.
cv2.imread('a.pgm',-1)
works.
You can also use skimage.io library
from skimage.io import imread
image = imread("a.pgm")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With