Thursday, March 12, 2009

RGB to CMY and YIQ conversion

% RGB to CMY and YIQ conversion
% Read a RGB Color image and convert it into CMY and YIQ formats
f=imread('onion.png');
f = im2double(f);
r=f(:,:,1);
g=f(:,:,2);
b=f(:,:,3);
c = 1-r;
m = 1-g;
y = 1-b;
CMY = cat(3,c,m,y);
figure,imshow(f),title('RGB');
figure,imshow(CMY),title('CMY');
Y = 0.3*r+0.59*g+0.11*b;
I = 0.6*r-0.28*g-0.32*b;
Q = 0.21*r-0.52*g+0.31*b;
YIQ =cat(3,Y,I,Q);
figure,imshow(YIQ),title('YIQ');

1 comment:

tony said...

Thanks, it was really useful