Image 获取图像的实际位深度

Image 获取图像的实际位深度,image,bit,depth,16-bit,Image,Bit,Depth,16 Bit,即使图像保存为16位文件,它通常也来自仅产生10或12位的相机。我希望能够检查图像文件的某些位(以及哪些位)是否始终为零 也就是说,摄像机产生xxxxxxxxxxx,它被写为xxxxxxxxxxx或000xxxxxxxxxx 编辑:这里有4个文件作为示例,分别为8位、10位、12位和16位:您可以使用以下命令在shell中使用ImageMagick获取位深度: magick identify -format "%[bit-depth]" 12-bit_000000.dpx

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

也就是说,摄像机产生
xxxxxxxxxxx
,它被写为
xxxxxxxxxxx
000xxxxxxxxxx


编辑:这里有4个文件作为示例,分别为8位、10位、12位和16位:

您可以使用以下命令在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
magick 12-bit_000000.dpx txt: 
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
样本输出

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)
      ...
      ...
...
...
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%)
...
...
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

您可以获得大量的十六进制像素转储,如下所示:

magick identify -verbose 12-bit_000000.dpx
magick 12-bit_000000.dpx txt: 
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
样本输出

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)
      ...
      ...
...
...
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%)
...
...
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

您可以找到如下最亮的像素:

magick identify -verbose 12-bit_000000.dpx
magick 12-bit_000000.dpx txt: 
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
这表明最亮的区域在附近(11441311),因此我们可以裁剪出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绑定


另一个选项是
exiftool

exiftool 10-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)
      ...
      ...
...
...
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%)
...
...
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
ExifTool版本号:12.00
文件名:10位_000000.dpx
目录:。
文件大小:12 MB
文件修改日期/时间:2021:02:08 09:50:32+00:00
文件访问日期/时间:2021:02:08 09:59:45+00:00
文件索引节点更改日期/时间:2021:02:08 09:50:32+00:00
文件权限:rw-r--r--
文件类型:DPX
文件扩展名:dpx
MIME类型:image/x-dpx
字节顺序:小端
标题版本:V2.0
DPX文件大小:12584960
同上键:新
图像文件名:10位_000000.dpx
创建日期:2021:02:01 10:45:32
创建者:flashSuite 2 3.4.5
项目:颜色测试
版权所有:2021
加密密钥:ffffffff
方向:水平(正常)
图像元素:1
图像宽度:2048
图像高度:1536
数据符号:无符号
组件配置:R、G、B

位深度:10可能会共享这样的图像(通过Dropbox或Google Drive),这样我们就可以看到您实际拥有的图像。这对于jpg等有损文件格式来说可能很困难。这种格式的色度子采样和插值可以引入像
XXYYY
这样的颜色,即使传感器只能创建
XX000
。你们有什么格式?另外,您计划使用什么编程语言?您已经尝试了什么?谢谢,Mark/Socowi。在本例中,它是一个未压缩的.dpx文件。明天我回到办公室后可以上传。我用4.dpx示例的下载链接更新了原始帖子。谢谢。非常感谢你,马克。这非常有帮助。很高兴它对你有用-祝你的项目好运。如果你陷入困境,回来问更多的问题-问题是免费的,答案也是免费的:-)