matlab 提取彩色部分的RGB

2025-01-20 12:13:09
推荐回答(2个)
回答1:

matlab 提取RGB颜色分量

a=imread('keli.tif');
[r,c,d]=size(a);

%提取红色分量
red=a;
red(:,:,1)=a(:,:,1);
red(:,:,2)=zeros(r,c);
red(:,:,3)=zeros(r,c);
red=unit8(red);

red=uint8(red);

subplot(131),imshow(red);

%

提取绿色分量

green=zeros(r,c);
green(:,:,2)=a(:,:,2);
green(:,:,1)=zeros(r,c);
green(:,:,3)=zeros(r,c);
green=uint8(green);
subplot(132),imshow(green);

%提取蓝色分量

blue=zeros(r,c);
blue(:,:,1)=zeros(r,c);
blue(:,:,2)=zeros(r,c);
blue(:,:,3)=a(:,:,3);

blue=uint8(blue);
subplot(133),imshow(blue);

回答2:

你好,下面的程序,我运行后怎么提示red=uint(red);出错那