【问题标题】:Getting the actual bit depth of an image获取图像的实际位深度
【发布时间】:2021-02-05 11:37:11
【问题描述】:

即使图像保存为 16 位文件,它通常也来自仅产生 10 或 12 位的相机。我希望能够检查图像文件的某些位以及哪些位始终为零。

即相机产生XXXXXXXXXXXX,它被写成XXXXXXXXXXXX00000000XXXXXXXXXXXX

编辑:这里以4个文件为例,8位、10位、12位和16位:https://filesender.uninett.no/?s=download&token=6a6f7f90-708d-4636-ba71-949acaaaded3

【问题讨论】:

  • 也许可以分享一张这样的图片(通过 Dropbox 或 Google Drive),这样我们就可以看到你实际拥有的东西。
  • 这对于 jpg 等有损文件格式可能会很困难。这种格式的色度二次采样和插值可以引入像XXYYY 这样的颜色,即使传感器只能创建XX000。你有什么格式?另外,您打算使用什么编程语言以及您已经尝试过什么?
  • 谢谢,马克/索科维。在本例中,它是一个未压缩的 .dpx 文件。明天我回到办公室时可以上传。
  • 我用 4 个 .dpx 示例的下载链接更新了原始帖子。谢谢。

标签: image bit depth 16-bit


【解决方案1】:

您可以在 shell 中使用 ImageMagick 获得位深度:

magick identify -format "%[bit-depth]"  12-bit_000000.dpx 
12

或者,一次性获取它们,以文件名为前缀:

magick identify -format "%f: %[bit-depth]\n"  *.dpx 
10-bit_000000.dpx: 10
12-bit_000000.dpx: 12
16-bit_000000.dpx: 16
8-bit_000000.dpx: 8

您可以像这样查看所有其他详细信息:

magick identify -verbose 12-bit_000000.dpx

样本输出

Image:
  Filename: 12-bit_000000.dpx
  Format: DPX (SMPTE 268M-2003 (DPX 2.0))
  Class: DirectClass
  Geometry: 2048x1536+0+0
  Units: Undefined
  Colorspace: sRGB
  Type: TrueColor
  Endianness: LSB
  Depth: 12-bit
  Channel depth:
    Red: 12-bit
    Green: 12-bit
    Blue: 12-bit
  Channel statistics:
    Pixels: 3145728
    Red:
      min: 0  (0)
      max: 2373 (0.579487)
      mean: 502.223 (0.122643)
      ...
      ...

您可以像这样获得 大量 十六进制像素转储:

magick 12-bit_000000.dpx txt: 

样本输出

...
...
118,2: (6897.58,6977.6,8017.83)  #1AF21B421F52  srgb(10.525%,10.6471%,12.2344%)
119,2: (6945.59,7121.63,8033.84)  #1B221BD21F62  srgb(10.5983%,10.8669%,12.2589%)
120,2: (6769.55,7329.68,7921.81)  #1A721CA21EF2  srgb(10.3297%,11.1844%,12.0879%)
121,2: (6465.48,7441.7,7825.79)  #19411D121E92  srgb(9.86569%,11.3553%,11.9414%)
...
...

你可以像这样找到最亮的像素:

identify -define identify:locate=maximum 12-bit_000000.dpx 

Channel maximum locations:
   Red: 37976.7 (0.579487) 1144,1311
   Green: 36376.3 (0.555067) 1146,1311
   Blue: 34808 (0.531136) 1146,1314

这告诉您最亮的区域在 (1144,1311) 附近,因此我们可以裁剪出该 4x4 区域并将其转为十六进制:

magick 12-bit_000000.dpx -crop 4x4+1144+1311 txt:

# ImageMagick pixel enumeration: 4,4,65535,srgb
0,0: (37976.7,36040.2,34407.9)  #94598CC88668  srgb(57.9487%,54.9939%,52.5031%)
1,0: (37672.6,36248.3,34455.9)  #93298D988698  srgb(57.4847%,55.3114%,52.5763%)
2,0: (37208.5,36376.3,34407.9)  #91598E188668  srgb(56.7766%,55.5067%,52.5031%)
3,0: (36808.4,36088.3,34055.8)  #8FC88CF88508  srgb(56.1661%,55.0672%,51.9658%)
0,1: (37880.7,35704.2,34055.8)  #93F98B788508  srgb(57.8022%,54.4811%,51.9658%)
1,1: (37544.6,36040.2,34151.8)  #92A98CC88568  srgb(57.2894%,54.9939%,52.1123%)
2,1: (37416.6,36360.3,34407.9)  #92298E088668  srgb(57.094%,55.4823%,52.5031%)
3,1: (37096.5,35992.2,34055.8)  #90E88C988508  srgb(56.6056%,54.9206%,51.9658%)
0,2: (37768.6,35592.1,33991.8)  #93898B0884C8  srgb(57.6313%,54.3101%,51.8681%)
1,2: (37544.6,35960.2,34183.8)  #92A98C788588  srgb(57.2894%,54.8718%,52.1612%)
2,2: (37528.6,35992.2,34487.9)  #92998C9886B8  srgb(57.265%,54.9206%,52.6252%)
3,2: (37464.6,35560.1,34279.8)  #92598AE885E8  srgb(57.1673%,54.2613%,52.3077%)
0,3: (37560.6,35624.2,34263.8)  #92B98B2885D8  srgb(57.3138%,54.359%,52.2833%)
1,3: (37336.5,35816.2,34519.9)  #91D98BE886D8  srgb(56.9719%,54.652%,52.674%)
2,3: (37544.6,35640.2,34808)  #92A98B3887F8  srgb(57.2894%,54.3834%,53.1136%)
3,3: (37688.6,34968,34439.9)  #933988988688  srgb(57.5092%,53.3578%,52.5519%)

希望您能看到每个样本的十六进制以 8 结尾,这意味着底部 3 位是清晰的。


ImageMagick 的 Python 绑定称为 wand


另一个选项是exiftool:

exiftool 10-bit_000000.dpx 

样本输出

ExifTool Version Number         : 12.00
File Name                       : 10-bit_000000.dpx
Directory                       : .
File Size                       : 12 MB
File Modification Date/Time     : 2021:02:08 09:50:32+00:00
File Access Date/Time           : 2021:02:08 09:59:45+00:00
File Inode Change Date/Time     : 2021:02:08 09:50:32+00:00
File Permissions                : rw-r--r--
File Type                       : DPX
File Type Extension             : dpx
MIME Type                       : image/x-dpx
Byte Order                      : Little-endian
Header Version                  : V2.0
DPX File Size                   : 12584960
Ditto Key                       : New
Image File Name                 : 10-bit_000000.dpx
Create Date                     : 2021:02:01 10:45:32
Creator                         : flashSuite 2 3.4.5
Project                         : Colour test
Copyright                       : 2021
Encryption Key                  : ffffffff
Orientation                     : Horizontal (normal)
Image Elements                  : 1
Image Width                     : 2048
Image Height                    : 1536
Data Sign                       : Unsigned
Components Configuration        : R, G, B
Bit Depth                       : 10              <--- HERE IT IS
Image Description               : 
Source File Name                : 
Source Create Date              : 
Input Device Name               : SpinnerS
Input Device Serial Number      : 5CFC3FE89CDB
Frame Rate                      : 16
Frame ID                        : 
Slate Information               : 
User ID                         : 
Image Size                      : 2048x1536
Megapixels                      : 3.1

【讨论】:

  • 非常感谢,马克。这非常有帮助。
  • 很高兴它为您工作 - 祝您的项目好运。如果您遇到困难,请回来问更多问题 - 问题是免费的,答案也是如此:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-11
  • 1970-01-01
相关资源
最近更新 更多