python - NumPy convert 8-bit to 16/32-bit image -
i using opencv 2 images manipulations in ycbcr color space. moment can detect noise due conversion rgb -> ycbcr , ycbcr -> rgb, said in documentation:
if use cvtcolor 8-bit images, conversion have information lost. many applications, not noticeable recommended use 32-bit images in applications need full range of colors or convert image before operation , convert back.
so convert image in 16 or 32 bits, didn't found how numpy. ideas?
img = cv2.imread(imgnamein) # here want convert img in 32 bits cv2.cvtcolor(img, cv2.color_bgr2ycr_cb, img) # image processing ... cv2.cvtcolor(img, cv2.color_ycr_cb2bgr, img) cv2.imwrite(imgnameout, img, [cv2.cv.cv_imwrite_png_compression, 0])
thanks @moarningsun, problem resolved:
i = cv2.imread(imgnamein, cv2.cv_load_image_color) # need sure have 8-bit input img = np.array(i, dtype=np.uint16) # line change type, not values img *= 256 # values in 16 bit format
Comments
Post a Comment