% clc
% clear all
% close all

function YyCxCz1 = rgb2ycxcz2(img_name)

img=imread(img_name);
% [row,col,l] = size(img);

%De-Gamma
img=255*((double(img)/255).^2.2);

%sRGB to XYZ
XYZ=sRGB2XYZ(img,50)/255;

%Indigo press white point
Xn=0.8594;
Yn=0.8872;
Zn=0.7945;

%XYZ to YCxCz
YyCxCz1(:,:,1)=116*(XYZ(:,:,2)/Yn);
YyCxCz1(:,:,2)=500*(XYZ(:,:,1)/Xn-XYZ(:,:,2)/Yn);
YyCxCz1(:,:,3)=200*(XYZ(:,:,2)/Yn-XYZ(:,:,3)/Zn);

% YyCxCz2 = reshape(YyCxCz1,row*col,l);
% 
% %Find all unique YyCxCz value in the image to do gamut mapping 
% %and then use ic and YyCxCzUnique to locate each point back to original image 
% [imgYyCxCzUnique, ia, ic] = unique(YyCxCz2,'rows');
% 
% 
% save data/imgYyCxCzUnique.mat imgYyCxCzUnique
% save data/ic.mat ic

