img=imread('4x3_RGB.tif');
img_double=double(img)./255;
Lab3=rgb2lab(img_double, 'WhitePoint','d50');
Lab = reshape(permute(Lab3,[3 1 2]),3,[]);
f = figure;
set(f,'PaperUnits','centimeters');
set(f,'name','plot_Lab - colorimg@ugr.es');
set(0,'units','pixels') ;
screen = get(0,'screensize');
set(f,'Position',[200,screen(4)-screen(4)/3-200,screen(3)/2,screen(4)/3]);
linewidth = 1;
cform = makecform('lab2srgb','AdaptedWhitePoint',whitepoint('D50'));
RGB = applycform(Lab',cform);
min_Lab = min(Lab,[],2);
max_Lab = max(Lab,[],2);
if min_Lab(1) > 0
min_Lab(1) = 0;
end
if min_Lab(2) > -100
min_Lab(2) = -100;
end
if min_Lab(3) > -100
min_Lab(3) = -100;
end
if max_Lab(1) < 100
max_Lab(1) = 100;
end
if max_Lab(2) < 100
max_Lab(2) = 100;
end
if max_Lab(3) < 100
max_Lab(3) = 100;
end
h=scatter3(Lab(3,:),Lab(2,:),Lab(1,:),80,RGB,'fill');
xlabel('b*'),ylabel('a*'),zlabel('L*');
title('CIE-L*a*b* coordinates');
axis([min_Lab(3) max_Lab(3) min_Lab(2) max_Lab(2) min_Lab(1) max_Lab(1)]);grid on;hold on;
line([min_Lab(3) max_Lab(3)],[0 0],[0 0],'color',[0 0 0],'lineWidth',linewidth);
line([0 0],[min_Lab(2) max_Lab(2)],[0 0],'color',[0 0 0],'lineWidth',linewidth);
line([0 0],[0 0],[min_Lab(1) max_Lab(1)],'color',[0 0 0],'lineWidth',linewidth);
h.DataTipTemplate.DataTipRows(1).Label = 'L=';
h.DataTipTemplate.DataTipRows(2).Label = 'a=';
h.DataTipTemplate.DataTipRows(3).Label = 'b=';
datatip(h, h.XData(1),h.YData(1),h.ZData(1));