NumPy convert 8-bit to 16/32-bit image

前端 未结 2 1546
我在风中等你
我在风中等你 2021-01-05 14:27

I am using OpenCV 2 to do some images manipulations in YCbCr color space. For the moment I can detect some noise due to the conversion RGB -> YCbCr and then YCbCr -> RGB, bu

2条回答
  •  佛祖请我去吃肉
    2021-01-05 14:58

    Thanks to @moarningsun, problem resolved:

    i = cv2.imread(imgNameIn, cv2.CV_LOAD_IMAGE_COLOR) # Need to be sure to have a 8-bit input
    img = np.array(i, dtype=np.uint16) # This line only change the type, not values
    img *= 256 # Now we get the good values in 16 bit format
    

提交回复
热议问题