2
votes

How to Convert RGB color Image or simply image to CMY color Image and Extract Each Component cyan (C) magenta (M) and yellow (Y) ? My approach :-

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
Don't have matlab right now. How is it not working? Does figure,imshow( cat(3,c,m,y)); work?Jay
@haraldK Now it gives black picsNEW USER
What if you try imshow(YourImage,[])Benoit_11
how about imshow(uint8(c*255))? Also btw you can do I3(:,:,[1,3])=0; in one lineDan

1 Answers

5
votes

You can use makecform to create color-space transformation:

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

BTW, in your question it seems like I is of type uint8 and therefore in range [0..255], to get the complement of each component, you need to subtract them from 255 and not 1.0:

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