如何将RBG三元组值转换为单值?单值介于0到255之间。单个值如何映射到彩色图像?

问题描述 投票:0回答:1

使用OpenCV,读取输入图像(蓝色背景图像圣诞树内)。

下图是输入图像。

enter image description here

读取图像的输出从蓝色背景变为红色。

enter image description here

当我在spyder中查看'image'变量的值时。这里3是RGB通道

enter image description here双击Axis = 0时显示的值。我理解的是BGR值

enter image description here

轴= 1,此处为0 BGR

enter image description here

轴= 2。我被困在这里。我不明白(像素)RBG值的三元组值如何转换为每个像素的单个值以及此像素(0,0)= 254如何表示此处的红色。

enter image description here

我知道黑白值在0到255之间变化。但是这里轴= 2(像素(0,0)= 254)表示红色(从读取图像的输出猜测)。

python opencv image-processing computer-vision color-theory
1个回答
1
投票

您正在使用OpenCV读取图像,其中它采用BGR颜色通道矩阵。但是,您使用其他一些将颜色通道矩阵作为RGB的库来显示它。使用cv2.cvtColor(image, cv2.BGR2RGB)将图像转换为RGB,然后显示它。

© www.soinside.com 2019 - 2024. All rights reserved.