我正在尝试将 8 位图像转换为 10 位。我认为这就像更改 bin 值一样简单。我试过枕头和 cv-python:
from PIL import Image
from numpy import asarray
import cv2
path = 'path/to/image'
img = Image.open(path)
data = asarray(img)
newdata = (data/255)*1023 #2^10 is 1024
img2 = Image.fromarray(newdata) #this fails
cv2.imwrite('path/newimage.png, newdata)
虽然cv2.imwrite
成功写入新文件,但即使 bin 达到 1023,它仍被编码为 8 位图像。
$ file newimage.png
newimage.png: PNG Image data, 640 x 480, 8-bit/color RGB, non-interlaced
在 python 或 linux 中是否有另一种方法可以将 8 位转换为 10 位?