How we can read 16 un signed integer(16 uint) jpeg

2020-07-22 18:00发布

问题:

How we can read the 16 uint jpeg images in python please suggest me the libraries which can read the these type of files in python. i tried matplotlib, scipy, scikit-image, medpy ,Pil ,opencv, numpy libraries. when we are using these libraries i am getting the out put as:

raise IOError("cannot identify image file")

IOError: cannot identify image file

please help me

find the file from the link

https://drive.google.com/file/d/0B4l5GiM7kBXraDEyMXdseENfUlE/edit?usp=sharing

回答1:

Having 16-bit JPEG images sounds a bit strange, as the JPEG standard does not support 16-bit images. It has 12-bit images, though. Unfortunately, most readers only support the usual 8-bits/pixel RGB images, so even with the 12-bit images this may be a bit challenging.

One useful test could be to try:

hdr = open("myimage.jpeg", "rb").read(2)
print "{:02x} {:02x}".format(ord(hdr[0]), ord(hdr[1]))

If your file is a JPEG file, it should start with:

ff d8

If you do not get those, then the file is something else. Is there any program you can use to open the file? Which program produced the files?



回答2:

This is the standard for 16bits grayscale lossless jpeg (recommendations ITU-T T.81). Now replaced with JPEG-LS and JPEG-2000.

This specific type of JPEG has single channel grayscale on a 16bits wide word, unlike 3 components RGB one on a 24bits/8 bits per channel.

Try using thorfdbg's libjpeg as it supports this type of old jpeg standard: https://github.com/thorfdbg/libjpeg