How do you distinguish RGB from another three-band color space?

getbands returns names for the bands in a mode. Equal band counts can represent different quantities.

Pixel experiment and interpretation

Think of two three-column tables with different headers. Feeding luma and chroma directly to an RGB model gives it the wrong columns.

from PIL import Image

[Image.new(m,(1,1)).getbands() for m in ('RGB','YCbCr')]

Result [('R', 'G', 'B'), ('Y', 'Cb', 'Cr')]

中文

怎样区分三通道 RGB 与三通道 YCbCr?

getbands 返回模式定义的通道名,通道数量相同并不表示通道含义相同。

像素实验与适用边界

两张三层表格,一张记录红绿蓝,另一张记录亮度和色差。把第二张直接送入要求 RGB 的模型会错读列名。

from PIL import Image

[Image.new(m,(1,1)).getbands() for m in ('RGB','YCbCr')]

结果 [('R', 'G', 'B'), ('Y', 'Cb', 'Cr')]

References / 参考来源

Keep reading / 继续阅读