简体   繁体   中英

cvtColor "code" for 16-bit grayscale images

I have unsigned 16-bit grayscale tiff images as numpy arrays. I want to do some image processing on these images using OpenCV. I am converting the numpy array to Mat format using cv2.cvtColor(src, code) . As far as the documentation goes, I am having a hard time finding the right code argument to correctly convert 16-bit grayscale images without losing any information.

Previously, I read the images directly using cv2.imread(src, cv2.IMREAD_UNCHANGED) . However, I don't have the original image files now, only the pickled numpy array. I am looking for the code in cvtColor which does a similar thing as cv2.IMREAD_UNCHANGED

Your question is tough to follow. All you appear to have are some files containing pickled Numpy arrays, correct?

If so, you don't need any imread() , you just need to unpickle the files and you will have Numpy arrays of the type that OpenCV uses to hold images. Check their dtype is np.uint16 and their shape appears correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM