【Matlab图像处理】学习笔记:提取图片的R,G,B分量

通过matlab一个小的程序把图片的R,G,B分量分别提取出来。

test
 1 clear
2 rgb=imread('李连杰.jpg');
3 rgb_r=rgb(:,:,1);
4 rgb_g=rgb(:,:,2);
5 rgb_b=rgb(:,:,3);
6 zero=zeros(200,160);
7 R=cat(3,rgb_r,zero,zero);
8 G=cat(3,zero,rgb_g,zero);
9 B=cat(3,zero,zero,rgb_b);
10 RGB=cat(3,rgb_r,rgb_g,rgb_b);
11 subplot(2,2,1),imshow(R),title('红色分量');
12 subplot(2,2,2),imshow(G),title('绿色分量');
13 subplot(2,2,3),imshow(B),title('蓝色分量');
14 subplot(2,2,4),imshow(RGB);

结果:

原文地址:https://www.cnblogs.com/tony1224/p/2430482.html