function plotLabColormapWithGamutAlarm(lab)
[first,last] = outOfGamutSegments(lab);
rgb = lab2rgb(lab);
ax = newplot;
colorSwatches(ax,rgb,0)
daspect(ax,[30 1 1])
xlim(ax,[0 size(lab,1)])
ylim(ax,[0 1.5])
axis(ax,"off")
hold(ax,"on")
y = [1.25 1.25];
for k = 1:length(first)
x1 = first(k) - 1;
x2 = last(k);
x = [x1 x2];
plot(ax,x,y,'r',LineWidth = 5)
end
hold(ax,"off")
end
function plotLabRGBColorsWithGamutAlarm(lab)
ax = newplot;
rgb = lab2rgb(lab);
hold(ax,"on")
plot(ax,rgb(:,1),'r')
plot(ax,rgb(:,2),'g')
plot(ax,rgb(:,3),'b')
xlim(ax,[1 - 0.05*height(rgb), 1.05*height(rgb)]);
y1 = min(-0.2,ax.YLim(1));
y2 = max(1.2,ax.YLim(2));
ylim(ax,[y1 y2]);
grid(ax,"on")
yline(ax,0, LineWidth = 5, Color = [0.7 0.7 0.7])
yline(ax,1, LineWidth = 5, Color = [0.7 0.7 0.7])
too_high = any(rgb > 1,2);
k = find(too_high);
if ~isempty(k)
plot(ax,k,ones(size(k)),'r*',MarkerSize = 6)
end
too_low = any(rgb < 0,2);
k = find(too_low);
if ~isempty(k)
plot(ax,k,zeros(size(k)),'r*',MarkerSize = 6)
end
hold(ax,"off")
end
function plotABWithGamutAlarm(lab)
ax = newplot;
plot(ax,lab(:,2),lab(:,3));
axis(ax,"equal")
xlim(ax,[-110 110])
ylim(ax,[-110 110])
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
xlabel("a")
ylabel("b")
[first,last] = outOfGamutSegments(lab);
hold on
for k = 1:length(first)
j1 = first(k);
j2 = last(k);
x = lab(j1:j2,2);
y = lab(j1:j2,3);
plot(ax,x,y,'r',LineWidth = 5)
end
hold off
grid(ax,"on")
end
function plotLWithGamutAlarm(lab)
ax = newplot;
plot(ax,lab(:,1));
xlim(ax,[1 - 0.05*height(lab), 1.05*height(lab)]);
ylim(ax,[-10 110])
[first,last] = outOfGamutSegments(lab);
hold on
for k = 1:length(first)
j1 = first(k);
j2 = last(k);
x = j1:j2;
y = lab(j1:j2,1);
plot(ax,x,y,'r',LineWidth = 5)
end
hold off
grid(ax,"on")
end
function [first,last] = outOfGamutSegments(lab)
rgb = lab2rgb(lab);
out_of_gamut_mask = any(rgb > 1,2) | any(rgb < 0,2);
d = diff([0 ; out_of_gamut_mask ; 0]);
first = find(d == 1);
last = find(d == -1) - 1;
end
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.