将RGB图像转换为CMY

时间:2015-04-21 14:12:13

标签: image matlab image-processing

如何将RGB彩色图像或简单图像转换为CMY彩色图像和提取每个组件青色(C)品红色(M)和黄色(Y)? 我的方法: -

I=imread('Capture2.PNG'); 
I3 = I;
I2 =I;
I1 = I;

I1(:,:,2:3)=0;
RED = I1;

I2(:,:,1:2) = 0;
BLUE = I2;

I3(:,:,1:3)=0;
GREEN=I3;

tic;
figure;imshow(RED);
figure;imshow(BLUE);
figure;imshow(GREEN);
c = 1.0-RED;
m = 1.0-GREEN;
y = 1.0-BLUE;
figure;imshow(c);
figure;imshow(m);
figure;imshow(y);

1 个答案:

答案 0 :(得分:4)

您可以使用makecform创建色彩空间转换:

I=imread('Capture2.PNG');
cform = makecform('srgb2cmyk');
cmykI = applycform(I,cform); 

BTW,在您的问题中,似乎I的类型为uint8,因此在范围[0..255]中,为了获得每个组件的补码,您需要从255中减去它们而不是1.0:

c = 255-RED;
m = 255-GREEN;
y = 255-BLUE;