%% 图像的RGB通道
pic=imread('1.jpg');
R = pic(:,:,1);%显示图像的三个通道
G = pic(:,:,2);
B = pic(:,:,3);
subplot(221),imshow(pic);
subplot(222),imshow(R);
subplot(223),imshow(G);
subplot(224),imshow(B);
%以上是分别分离处图像的RGB通道,并分别显示出来,
%对于R通道,彩 {MOD}图像红 {MOD}区域在R通道中显示发亮,
%对于G通道,彩 {MOD}图像绿 {MOD}区域在G通道中显示发亮,
%对于B通道,彩 {MOD}图像蓝 {MOD}区域在B通道中显示发亮,
figure;
r = pic;
g = pic;
b = pic;
r(:,:,2) = 0;
r(:,:,3) = 0;
g(:,:,1) = 0;
g(:,:,3) = 0;
b(:,:,1) = 0;
b(:,:,2) = 0;
subplot(221),imshow(pic);
subplot(222),imshow(r);
subplot(223),imshow(g);
subplot(224),imshow(b);
%显示出来的的矩阵r g b仍然是彩 {MOD}图像,只是对于矩阵r将g通道和b通道都置0,
%对于矩阵g将r通道和b通道都置0,对于矩阵b将r通道和g通道都置0,也可以将其中一个通道置为0,
%或者置为其他数值,但显示出来的矩阵r、g、b是彩 {MOD}图像
r(:,:,2) = 200;
r(:,:,3) = 100;
g(:,:,1) = 50;
g(:,:,3) = 60;
b(:,:,1) = 80;
b(:,:,2) = 20;
%% 或者是
r(:,:,2) = 200;
g(:,:,1) = 50;
b(:,:,2) = 20;
分离图像的RGB通道
将三通道中的某一个或者两个通道的值改变,并将矩阵进行显示,显示的是彩 {MOD}图像
若是
r = pic;
g = pic;
b = pic;
r(:,:,2) = 0;
r(:,:,3) = 0;
g(:,:,1) = 0;
g(:,:,3) = 0;
b(:,:,1) = 0;
b(:,:,2) = 0;
若是
r = pic;
g = pic;
b = pic;
r(:,:,2) = 200;
r(:,:,3) = 100;
g(:,:,1) = 50;
g(:,:,3) = 60;
b(:,:,1) = 80;
b(:,:,2) = 20;
若是
r(:,:,2) = 200;
g(:,:,1) = 50;
b(:,:,2) = 20;