【发布时间】:2020-10-26 16:53:35
【问题描述】:
我正在尝试将 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 位?
【问题讨论】:
-
为什么需要 10 位图像?这是非常罕见和低效的(在性能的情况下)。您的处理器和内存可能无法很好地处理 10 位数据。
标签: python opencv ubuntu python-imaging-library bit-depth