当我尝试对原始数据进行jpeg解压缩(老式的jpeg压缩,不是jpeg-ls,也不是jpeg2000)时,我得到以下错误:
Traceback (most recent call last):
File "raw-reader.py", line 766, in <module>
raw_image_data = imageio.imread(io.BytesIO(raw_packed_image_data))
File "/home/ian/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 206, in imread
reader = read(uri, format, 'i', **kwargs)
File "/home/ian/.local/lib/python3.6/site-packages/imageio/core/functions.py", line 129, in get_reader
return format.get_reader(request)
File "/home/ian/.local/lib/python3.6/site-packages/imageio/core/format.py", line 168, in get_reader
return self.Reader(self, request)
File "/home/ian/.local/lib/python3.6/site-packages/imageio/core/format.py", line 217, in __init__
self._open(**self.request.kwargs.copy())
File "/home/ian/.local/lib/python3.6/site-packages/imageio/plugins/pillow.py", line 398, in _open
pilmode=pilmode, as_gray=as_gray)
File "/home/ian/.local/lib/python3.6/site-packages/imageio/plugins/pillow.py", line 122, in _open
self._im = factory(self._fp, '')
File "/home/ian/.local/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 780, in jpeg_factory
im = JpegImageFile(fp, filename)
File "/home/ian/.local/lib/python3.6/site-packages/PIL/ImageFile.py", line 102, in __init__
self._open()
File "/home/ian/.local/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 339, in _open
handler(self, i)
File "/home/ian/.local/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 166, in SOF
raise SyntaxError("cannot handle %d-bit layers" % self.bits)
SyntaxError: cannot handle 14-bit layers
图像中的原始数据是14位jpeg数据,ImageIO无法读取。当我尝试使用枕头时,它甚至没有识别出数据是jpeg。我现在的问题是:如何在不编写自己的jpeg解压器的情况下解压数据,同时记住数据是14位的?
我的代码:
import io
import imageio
allbytes = open("raw_data.dat", "rb").read()
raw_packed_image_data = allbytes
raw_image_data = imageio.imread(io.BytesIO(raw_packed_image_data))
文件
raw_data.dat
是一个纯包含用jpeg压缩的原始图像数据的文件。链接到
raw_data.dat