本文介绍了确定JPEG的色彩空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写用于确定JPEG图像颜色空间的代码.我发现了两个可以帮助我实现这一目标的参考.一个在 oracle.com上,另一个是 ijg.com 中的C源代码,其中负责原始JPEG标准的参考实现".

I am writing a code for determining a JPEG image's color space. I have found two references that may help me implementing this. One is on the oracle.com, the other one is a C source code from the ijg.com which "is responsible for the reference implementation of the original JPEG standard".

但是它们确实有所不同.例如.在IJG中,当没有Adobe标记并且有4个通道时,它假定为CMYK,而在oracle中,它是YCCA.同样,IJG的实现也不是在子采样上,而对于4通道子采样,在Oracle规范中是YCCK,依此类推.

However they do differ. E.g. in IJG when there is no Adobe marker and there are 4 channels it is assumed as CMYK, but in oracle it is YCCA. Also IJG's implementation doesn't look on subsampling, whereas for 4-channel subsampled it is YCCK in oracle specs, and so on.

在ColorSpace类中也有很多缺失,当我实现oracle的逻辑时,我需要指定3个额外的颜色空间,例如YCCK,YCCA,RGBA.

Also there are many missings in ColorSpace class, when I implemented the oracle's logic I needed to specify 3 extra color spaces, like YCCK, YCCA, RGBA.

另一点是,我在alpha通道这里,为什么Oracle在JPEG metadat规范的背景下谈论YCCA和RGBA?

Another point is that I found information that JPEG does not support transparency in alpha channel here, why would oracle talk about YCCA and RGBA in the context of JPEG metadat specification?

结果是,当使用IJG的逻辑检查图像时,它告诉我它是CMYK(在ubuntu上使用ImageMagick检查了该图像,它也说它是CMYK),而使用oracle的逻辑是YCCA.谁相信? oracle为什么不依赖原始的JPEG规范?还是我不知道的其他东西?

In result when checking an image with IJG's logic it tells me it is CMYK (checked the image with ImageMagick on ubuntu and it also says it is CMYK), with oracle's logic it is YCCA. Who to believe? Why would oracle not rely on the original JPEG specification? Or there is something else I don't know?

推荐答案

在对旧的JPEG标准进行评论之后,我终于找到了答案.

After my comments on old JPEG standars, I finally found the answer.

ISO/IEC 10918-6:2013( E),第6.1节:

除非有图像,否则假定使用三个分量编码的图像是编码为YCbCr的RGB数据. 包含6.5.3中指定的APP14标记段,在这种情况下,应考虑颜色编码 根据APP14标记段的应用数据选择RGB还是YCbCr.关系 RGB和YCbCr之间的关系如Rec.4中所定义. ITU-T T.871 | ISO/IEC 10918-5.

Images encoded with three components are assumed to be RGB data encoded as YCbCr unless the image contains an APP14 marker segment as specified in 6.5.3, in which case the colour encoding is considered either RGB or YCbCr according to the application data of the APP14 marker segment. The relationship between RGB and YCbCr is defined as specified in Rec. ITU-T T.871 | ISO/IEC 10918-5.

使用四个分量编码的图像假定为 CMYK ,其中(0,0,0,0)表示白色,除非 图像包含6.5.3中指定的APP14标记段,在这种情况下,颜色编码为 根据APP14标记片段的应用数据,将其视为 CMYK YCCK .这 CMYK YCCK 之间的关系如第7节中所定义.

Images encoded with four components are assumed to be CMYK, with (0,0,0,0) indicating white unless the image contains an APP14 marker segment as specified in 6.5.3, in which case the colour encoding is considered either CMYK or YCCK according to the application data of the APP14 marker segment. The relationship between CMYK and YCCK is defined as specified in clause 7.

,APP14标志为"Adobe\0",AP12具有转换标志:

and the APP14 flags is "Adobe\0", the AP12 has the transform flag:

0 – CMYK用于使用四个分量编码的图像,其中所有四个CMYK值均为 补充RGB,用于用三个分量编码的图像;即APP14标记不 指定应用于图像数据的变换.

0 – CMYK for images that are encoded with four components in which all four CMYK values are complemented; RGB for images that are encoded with three components; i.e., the APP14 marker does not specify a transform applied to the image data.

1 –使用YCbCr颜色编码对具有三个分量的图像进行编码.

1 – An image encoded with three components using YCbCr colour encoding.

2 –使用YCCK颜色编码对具有四个分量的图像进行编码.

2 – An image encoded with four components using YCCK colour encoding.

因此,这取决于:应该为CMYK,但如果APP14和AP12的值正确,则可能为YCCK.

So, it depends: it should be CMYK, but it could be YCCK if APP14 and AP12 have the right values.

这篇关于确定JPEG的色彩空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 05:06