图像中的第 4 个通道是什么?

What is the 4th channel in an image?

当使用 np.random.randint

随机生成图像时,该列意味着什么
img = np.random.randint(255, size=(4,4,3), dtype='uint8')

这将创建一个 4 x 4 像素的 3 列矩阵。

img = np.random.randint(255, size=(4,4,4), dtype='uint8')

这将创建一个 4 x 4 像素,具有 4 列的矩阵。

在这种情况下,矩阵中列的作用是什么?

问得好。我们通常称频道为您所说的专栏。


一张RGB图像有3个通道:红色、绿色和蓝色。

一张CMYK图像有四个通道:青色、品红色、黄色和黑色。


视觉上:

不能说像素的组成部分代表什么。或者至少不确定。这取决于color space [wiki]你select.

为了存储颜色,您需要表示该颜色。有几种方法可以做到这一点。一种常见的方法是使用 RGB color model [wiki]. Where one uses three channels: one for Red, one for Green and one for Blue. This model is based on the assumption that the human eye has three kinds of light receptors, for each of these colors. It is common in for monitors as well, since a computer monitor has three sorts of subpixels 每个渲染一个颜色通道。有时会添加一个额外的通道 Alpha,使其成为 ARGB 配色方案。然后,alpha 通道描述了该像素的透明度级别。例如,如果您想要将一张图片添加到另一张图片上,以及图片的某些部分,这将非常有用。

另一种颜色系统是HSL color system,其中颜色space被看作是圆柱形的一个,三个属性Hue,S饱和度,L亮度分别描述了圆柱体中的角度、半径和高度。这与 RGB 颜色系统形成对比,可以将其视为立方体。

出于打印目的,通常使用 CMYK color model:使用 Cyan 的频道,Magent,Yellow 和 Black。这些通常是基本打印机中的墨盒。

简而言之,您无法分辨配色方案是什么。根据 numpy,这只是一个 4×4×34×4×4 数组。只有 解释 数字,例如根据配色方案,我们才能理解它。

OpenCV 具有将一种配色方案转换为另一种配色方案的功能。如您所见,它也支持大范围的conversions. It has extensive documentation on the color schemes