【问题标题】:How we can read 16 un signed integer(16 uint) jpeg files in python我们如何在 python 中读取 16 个无符号整数(16 uint)jpeg 文件
【发布时间】:2014-09-09 10:14:34
【问题描述】:

我们如何在 python 中读取 16 个 uint jpeg 图像 请向我推荐可以在 python 中读取这些类型文件的库。 我尝试了 matplotlib、scipy、scikit-image、medpy、Pil、opencv、numpy 库。 当我们使用这些库时,我得到的输出是:

raise IOError("cannot identify image file")

IOError: cannot identify image file

请帮帮我

从链接中查找文件

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

【问题讨论】:

标签: python opencv numpy matplotlib


【解决方案1】:

拥有 16 位 JPEG 图像听起来有点奇怪,因为 JPEG 标准不支持 16 位图像。不过,它有 12 位图像。不幸的是,大多数阅读器只支持通常的 8 位/像素 RGB 图像,因此即使使用 12 位图像,这也可能有点挑战。

一个有用的测试可能是尝试:

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

如果您的文件是 JPEG 文件,则应以:

ff d8

如果你没有得到这些,那么文件就是别的东西。有什么程序可以用来打开文件吗?哪个程序生成了这些文件?

【讨论】:

  • 我可以使用这些代码读取图像。但我需要为基于医学领域的项目读取此图像的每个像素值。所以请帮我打印此图像的实际像素值数组。感谢您的支持
  • 这张图片可以被 mathlab 读取,输出如下所示 i = imfinfo('di.jpg') i = Filename: [1x56 char] FileModDate: '14-Jul-2014 15:22:13 ' FileSize: 1044064 Format: 'jpg' FormatVersion: '' Width: 1024 Height: 1024 BitDepth: 16 ColorType: 'grayscale' FormatSignature: '' NumberOfSamples: 1 CodingMethod: 'Huffman' CodingProcess: 'Lossless' Comment: {'Created by AccuSoft Corp.'}
【解决方案2】:

这是 16 位灰度无损 jpeg 的标准(建议 ITU-T T.81)。现在替换为 JPEG-LS 和 JPEG-2000。

这种特定类型的 JPEG 在 16 位宽的字上具有单通道灰度,这与在 24 位/每通道 8 位上的 3 个分量 RGB 不同。

尝试使用 thorfdbg 的 libjpeg,因为它支持这种类型的旧 jpeg 标准:https://github.com/thorfdbg/libjpeg

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 1970-01-01
    相关资源
    最近更新 更多