function preprocessGamutPlot


%preprocessGamutPlot allows you to display 
% 1. HP Indigo press gamut, called destination gamut in YyCxCz color space
% 2. image gamut, called source gamut in YyCxCz color space 
% 3. Destination gamut and source gamut in one plot
% 4. Yy vs. Cx plot
% 5. Cx vs. Cz plot

    close all
    
    load('data/IndigoGamut.mat')%Indigo/Destination Gamut
    load('data/imgYyCxCzUnique.mat')%Image/Source gamut
    load('data/np8_ycxcz_measured.mat')% 8 vertices from Indigo gamut, use for plotting

    vertices=np8_ycxcz(:,4:6)';

    %plot Destination Gamut
    figure(1)
    plot3(IndigoGamut(:,2),IndigoGamut(:,3),IndigoGamut(:,1),'.','MarkerSize',5)
    hold on
    plot3(vertices(2,:),vertices(3,:),vertices(1,:),'.','MarkerSize',20)
    grid on
    xlabel('Cx')
    ylabel('Cz')
    zlabel('Yy')
    text(vertices(2,1),vertices(3,1),vertices(1,1)+.1,'W');
    text(vertices(2,2),vertices(3,2),vertices(1,2)+.1,'Y');
    text(vertices(2,3),vertices(3,3),vertices(1,3)+.1,'C');
    text(vertices(2,4),vertices(3,4),vertices(1,4)-.1,'CY');
    text(vertices(2,5),vertices(3,5),vertices(1,5)+.1,'M');
    text(vertices(2,6),vertices(3,6),vertices(1,6)+.1,'MY');
    text(vertices(2,7),vertices(3,7),vertices(1,7)+.1,'CM');
    text(vertices(2,8),vertices(3,8),vertices(1,8)-.1,'CMY');
    title('Destination gamut')
    name = sprintf('gamut_dest.png');
    saveas(gca,[pwd '/output/',name]);

    %Plot Source Gamut
    figure(2)
    plot3(imgYyCxCzUnique(:,2),imgYyCxCzUnique(:,3),imgYyCxCzUnique(:,1),'.','MarkerSize',5)
    grid on
    xlabel('Cx')
    ylabel('Cz')
    zlabel('Yy')
    title('Source gamut before gamut mapping')
    name = sprintf('gamut_src_beforeGamutMapping.png');
    saveas(gca,[pwd '/output/',name]);

    figure(3)
    plot3(imgYyCxCzUnique(:,2),imgYyCxCzUnique(:,3),imgYyCxCzUnique(:,1),'.','MarkerSize',5)
    hold on
    plot3(IndigoGamut(:,2),IndigoGamut(:,3),IndigoGamut(:,1),'.','MarkerSize',5)
    hold on
    plot3(vertices(2,:),vertices(3,:),vertices(1,:),'.','MarkerSize',20)
    grid on
    xlabel('Cx')
    ylabel('Cz')
    zlabel('Yy')
    text(vertices(2,1),vertices(3,1),vertices(1,1)+.1,'W');
    text(vertices(2,2),vertices(3,2),vertices(1,2)+.1,'Y');
    text(vertices(2,3),vertices(3,3),vertices(1,3)+.1,'C');
    text(vertices(2,4),vertices(3,4),vertices(1,4)-.1,'CY');
    text(vertices(2,5),vertices(3,5),vertices(1,5)+.1,'M');
    text(vertices(2,6),vertices(3,6),vertices(1,6)+.1,'MY');
    text(vertices(2,7),vertices(3,7),vertices(1,7)+.1,'CM');
    text(vertices(2,8),vertices(3,8),vertices(1,8)-.1,'CMY');
    title('Source and destination gamut before gamut mapping')
    name = sprintf('gamut_src_dest_beforeGamutMapping.png');
    saveas(gca,[pwd '/output/',name]);
    
    figure(4)
    plot(imgYyCxCzUnique(:,2),imgYyCxCzUnique(:,1),'.','MarkerSize',5)
    hold on
    plot(IndigoGamut(:,2),IndigoGamut(:,1),'.','MarkerSize',5)
    hold on
    plot(vertices(2,:),vertices(1,:),'.','MarkerSize',20)
    grid on
    legend('Source gamut','Destination gamut')
    xlabel('Cx')
    ylabel('Yy')
    text(vertices(2,1),vertices(1,1)+.1,'W');
    text(vertices(2,2),vertices(1,2)+.1,'Y');
    text(vertices(2,3),vertices(1,3)+.1,'C');
    text(vertices(2,4),vertices(1,4)-.1,'CY');
    text(vertices(2,5),vertices(1,5)+.1,'M');
    text(vertices(2,6),vertices(1,6)+.1,'MY');
    text(vertices(2,7),vertices(1,7)+.1,'CM');
    text(vertices(2,8),vertices(1,8)-.1,'CMY');
    title('Source and destination gamut before gamut mapping Yy vs. Cx view')
    name = sprintf('gamut_src_dest_beforeGamutMapping Yy vs. Cx view.png');
    saveas(gca,[pwd '/output/',name]);
    
    figure(5)
    plot(imgYyCxCzUnique(:,2),imgYyCxCzUnique(:,3),'.','MarkerSize',5)
    hold on
    plot(IndigoGamut(:,2),IndigoGamut(:,3),'.','MarkerSize',5)
    hold on
    plot(vertices(2,:),vertices(3,:),'.','MarkerSize',20)
    grid on
    legend('Source gamut','Destination gamut')
    xlabel('Cx')
    ylabel('Cz')
    text(vertices(2,1),vertices(3,1)+.1,'W');
    text(vertices(2,2),vertices(3,2)+.1,'Y');
    text(vertices(2,3),vertices(3,3)+.1,'C');
    text(vertices(2,4),vertices(3,4)-.1,'CY');
    text(vertices(2,5),vertices(3,5)+.1,'M');
    text(vertices(2,6),vertices(3,6)+.1,'MY');
    text(vertices(2,7),vertices(3,7)+.1,'CM');
    text(vertices(2,8),vertices(3,8)-.1,'CMY');
    title('Source and destination gamut before gamut mapping Cx vs. Cz view')
    name = sprintf('gamut_src_dest_beforeGamutMapping Cx vs. Cz view.png');
    saveas(gca,[pwd '/output/',name]);
    
    close all
end
