获取图像的实际位深

问题描述

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

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

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

解决方法

您可以在 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,34151.8)  #92A98CC88568  srgb(57.2894%,52.1123%)
2,1: (37416.6,36360.3,34407.9)  #92298E088668  srgb(57.094%,55.4823%,1: (37096.5,35992.2,34055.8)  #90E88C988508  srgb(56.6056%,54.9206%,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,34487.9)  #92998C9886B8  srgb(57.265%,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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...