【发布时间】:2016-03-20 21:13:06
【问题描述】:
Matlab 将图像存储为 3 维数组。前两个维度对应于上图轴上的数字。每个像素由图像第三维中的三个条目表示。三层中的每一层都代表像素阵列中红色、绿色和蓝色的强度。我们可以通过以下方式提取图像的独立红绿蓝分量:
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
如果您将这些通道之一与两个黑色矩阵(零矩阵)连接,您将获得彩色图像。让我们将每个通道与剩余通道的黑色图像矩阵连接起来:
blackImage = uint8(zeros(rows, columns));
newRedChannel = cat(3, redChannel, blackImage, blackImage);
newGreenChannel = cat(3, blackImage, greenChannel, blackImage);
newBlueChannel = cat(3, blackImage, blackImage, blueChannel);
为什么会这样?为什么每种颜色的单个通道必须与剩余通道的零矩阵(黑色图像)连接,以便在显示时对其进行着色?如果单独显示,为什么单个颜色通道实际上只是灰度图像?
【问题讨论】:
标签: image matlab image-processing rgb