Coloring axis with gradients?

조회 수: 2(최근 30일)
Roger Breton
Roger Breton 2022년 1월 16일
답변: Matt J 2022년 1월 16일
My humble script is taking shape :
Here's my code, for those interested :
global sRGBGamut AdobeRGBGamut EpsonGamut P3Gamut Rec2020Gamut ax;
popup = uicontrol('Style', 'popup',...
'String', {'sRGB','AdobeRGB','P3','Epson','Rec2020'},...
'Position', [10 10 100 50],'background','green',...
% 1 Créer l'échantillon RGB
[r,g,b] = meshgrid(linspace(0,1,20)); % linspace(0,1,50)
rgb = [r(:), g(:), b(:)];
% lab sert d'Input à la conversion de profil ICC
lab = rgb2lab(rgb); % Input - double (0.0 à 1.0)
lab2 = rgb2lab(rgb,'ColorSpace','adobe-rgb-1998');
a = lab(:,2);
b = lab(:,3);
L = lab(:,1);
k = boundary(a,b,L);
sRGBGamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
axis([-128 128 -128 128 0 100]);;grid on;hold on;
title('sRGB gamut surface', 'in L*a*b* space'); % Add Title to Current Axes
ax.TitleHorizontalAlignment = 'left';
a = lab2(:,2);
b = lab2(:,3);
L = lab2(:,1);
k = boundary(a,b,L);
AdobeRGBGamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
set(AdobeRGBGamut, 'Visible', 'off');
% 2 Profil Epson ------------------------------------------------------
EpsonProf = iccread('SC5M E240 FD9 basICColor (2021 12 11).icm');
cform_LabEpson = makecform('clut',EpsonProf,'AToB1')
LabEpson = applycform(rgb,cform_LabEpson);
a = LabEpson(:,2);
b = LabEpson(:,3);
L = LabEpson(:,1);
k = boundary(a,b,L);
EpsonGamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
set(EpsonGamut, 'Visible', 'off');
% 3 Profil P3 ------------------------------------------------------
P3Prof = iccread('Display P3.icm');
cform_XYZP3 = makecform('mattrc',P3Prof,'Direction','forward') % Output is XYZ
xyzP3 = applycform(rgb, cform_XYZP3);
cform_XYZ2Lab = makecform('xyz2lab')
LabP3 = applycform(xyzP3, cform_XYZ2Lab)
a = LabP3(:,2);
b = LabP3(:,3);
L = LabP3(:,1);
k = boundary(a,b,L);
P3Gamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
set(P3Gamut, 'Visible', 'off');
% 4 Profil Rec2020 ------------------------------------------------------
Rec2020Prof = iccread('Rec2020-Rec1886.icc');
cform_XYZrec2020 = makecform('mattrc',Rec2020Prof,'Direction','forward') % Output is XYZ
xyzRec2020 = applycform(rgb, cform_XYZrec2020);
LabRec2020 = applycform(xyzRec2020, cform_XYZ2Lab);
a = LabRec2020(:,2);
b = LabRec2020(:,3);
L = LabRec2020(:,1);
k = boundary(a,b,L);
Rec2020Gamut = trisurf(k,a,b,L,'FaceColor','interp', 'FaceVertexCData',rgb,'EdgeColor','none');
set(Rec2020Gamut, 'Visible', 'off');
function popupCallback(popup,event)
sels = get(popup,'String');
idx = get(popup,'Value');
Selection = sels{idx};
global sRGBGamut;
global AdobeRGBGamut;
global EpsonGamut;
global P3Gamut;
global Rec2020Gamut;
case 'sRGB'
title('sRGB gamut surface', 'in L*a*b* space');
set(AdobeRGBGamut, 'Visible', 'off');
set(EpsonGamut, 'Visible', 'off');
set(P3Gamut, 'Visible', 'off');
set(Rec2020Gamut, 'Visible', 'off');
set(sRGBGamut, 'Visible', 'on');
fprintf('sRGB\n' );
case 'AdobeRGB'
title('AdobeRGB gamut surface', 'in L*a*b* space');
set(sRGBGamut, 'Visible', 'off');
set(EpsonGamut, 'Visible', 'off');
set(P3Gamut, 'Visible', 'off');
set(Rec2020Gamut, 'Visible', 'off');
set(AdobeRGBGamut, 'Visible', 'on');
fprintf('AdobeRGB\n' );
case 'P3'
title('Display P3 gamut surface', 'in L*a*b* space');
set(EpsonGamut, 'Visible', 'off');
set(sRGBGamut, 'Visible', 'off');
set(AdobeRGBGamut, 'Visible', 'off');
set(Rec2020Gamut, 'Visible', 'off');
set(P3Gamut, 'Visible', 'on');
fprintf('P3\n' );
case 'Epson'
title('Epson P5000 gamut surface', 'in L*a*b* space');
set(sRGBGamut, 'Visible', 'off');
set(AdobeRGBGamut, 'Visible', 'off');
set(Rec2020Gamut, 'Visible', 'off');
set(P3Gamut, 'Visible', 'off');
set(EpsonGamut, 'Visible', 'on');
fprintf('Epson\n' );
case 'Rec2020'
title('Rec2020 gamut surface', 'in L*a*b* space');
set(EpsonGamut, 'Visible', 'off');
set(sRGBGamut, 'Visible', 'off');
set(AdobeRGBGamut, 'Visible', 'off');
set(P3Gamut, 'Visible', 'off');
set(Rec2020Gamut, 'Visible', 'on');
fprintf('Rec2020\n' );
% fprintf('Invalid grade\n' );
Any criticism is welcome, by the way, I'm by no means a Matlab expert... but I am a little bit knowledgeable about ICC profiles and their internal workings, which help untangle the many cform function calls.
I wasn't expecting the Rec2020 gamut to be truncated along the a* axis? Very interesting. I already have the axis defined between -128 to +128 which corresponds, in my understanding, to a signed 8bit value.
Question, if I may : how could I possibly add gradients axis? I would lilke to be able to create something along those lines, so that, when the student rotate the plot, we always have a visual reference point :
Are gradients possible at all in Matlab? I confess I have not found anything in the documentation...


Matt J
Matt J 2022년 1월 16일
Do you mean colorbar()?




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by