radiobutton to switch between scatter3 datasets?

1 visualización (últimos 30 días)
Roger Breton
Roger Breton el 23 de Dic. de 2021
Respondida: Roger Breton el 23 de Dic. de 2021
I would like to extend the vizualisation in my scatter3 project to inGamut colors. Right now, what I have is this :
The points represent the unconverted sRGB colors in Lab. The data tip shows both these Lab coordinates and how far they are relative to the Destination gamut. But I would like to have a radio button that would toggle between the unconverted sRGB "Lab" colors and the converted colors, once converted with applycform to the Desination gamut. Based on my experience with the Opacity slider control, I figure my code to add this functionality could be as follows :
% First, define the control
uicontrol('Style', 'radiobutton', ______, 'Callback', {@radiobuttonCB, h}); % h is the handle of the scatter3 figure
% Then, the callback
function radiobuttonCB(SliderH, EventData, h)
h=scatter3(LabIN(2,:),LabIN(3,:),LabIN(1,:),80,RGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
end
The initial scatter3 function is this :
h=scatter3(Lab(2,:),Lab(3,:),Lab(1,:),80,RGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
I'm not sure I can simply 're-call' the scatter3 with the new X,Y, Z parameters? How should I proceed?
And then, I'll to come up with some logic to toggle back to the original Lab data... Oh boy!
  1 comentario
Roger Breton
Roger Breton el 23 de Dic. de 2021
Oops! I found the example code in the Help. Now, my figure looks like this :
So, it looks like I have to do my stuff in the callback function, shown this way in the Help documentation :
function bselection(source,event)
disp(['Previous: ' event.OldValue.String]);
disp(['Current: ' event.NewValue.String]);
disp('------------------');
end
I guess, then, I should reformulate my question, can I simply 're-call' or 're-issue' the scatter3 function from within this callback function :
function bselection(source,event)
h=scatter3(LabIN(2,:),LabIN(3,:),LabIN(1,:),80,RGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
end
Thanks in advance for your help and patience... I'll continue my research in case...

Iniciar sesión para comentar.

Respuesta aceptada

Roger Breton
Roger Breton el 23 de Dic. de 2021
After much work, I got the solution working, although it is far from elegant. I had to define a bunch of global... I'll loop into app properties -- promised. This is the code I use :
function bselection(source,event)
global LabIMG LabIMG_Epson rawRGB imgRGB a b L k rgb DE76
if event.NewValue.String == "Epson"
hold off
h=scatter3(LabIMG_Epson(2,:),LabIMG_Epson(3,:),LabIMG_Epson(1,:),80,imgRGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
else
hold off
h=scatter3(LabIMG(2,:),LabIMG(3,:),LabIMG(1,:),80,rawRGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
end
hold on
h1 = trisurf(k,a,b,L,'FaceColor','interp','FaceVertexCData',rgb,'EdgeColor','none', 'FaceAlpha', 0.5)
linewidth = 1
xlabel('b*'),ylabel('a*'),zlabel('L*');
title('CIE-L*a*b* coordinates');
axis([-128 128 -128 128 0 100]);grid on;hold on;
% draw black lines indicating axis
line([-128 128],[0 0],[0 0],'color',[1 0 0],'lineWidth',linewidth); % Axis L* == a* == 0
line([0 0],[-128 128],[0 0],'color',[0 1 0],'lineWidth',linewidth); % Axis L* == b* == 0
line([0 0],[0 0],[0 100],'color',[0 0 1],'lineWidth',linewidth); % Axis a* == b* == 0
% Redefine labels
h.DataTipTemplate.DataTipRows(1).Label = 'b'; % X
h.DataTipTemplate.DataTipRows(2).Label = 'a='; % Y
h.DataTipTemplate.DataTipRows(3).Label = 'L='; % Z
row = dataTipTextRow('DE76=',DE76(:));
h.DataTipTemplate.DataTipRows(end+1) = row;
% Show datatip
% Syntaxe: datatip(target,x,y,z)
datatip(h, h.XData(1),h.YData(1),h.ZData(1));
disp(['Previous: ' event.OldValue.String]);
disp(['Current: ' event.NewValue.String]);
disp('------------------');
end
The code "ballooned" because I had to "repeat" figure setup code.
For now, I don't really care since I'm at a very experimental stage...
Thank you Chris!

Más respuestas (1)

Cris LaPierre
Cris LaPierre el 23 de Dic. de 2021
Right now, your color is set by your variable RGB (which appears to be undefined in the callback function you have shared). So long as this variable gets updated with your desired colors, yes, you can just re-call the bSelection function.
However, we are unaware of what other code may exist inside this callback function. Whether this is the right approach or not will have to be decided by you after taking that into consideration.
  12 comentarios
Roger Breton
Roger Breton el 23 de Dic. de 2021
Editada: Roger Breton el 23 de Dic. de 2021
Too late!
I got this new code working :
function bselection(source,event)
global LabIMG_Epson imgRGB a b L k rgb
hold off
h=scatter3(LabIMG_Epson(2,:),LabIMG_Epson(3,:),LabIMG_Epson(1,:),80,imgRGB,'fill', 'MarkerEdgeColor', [0,0,0], 'Linewidth', 1.3);
hold on
h1 = trisurf(k,a,b,L,'FaceColor','interp','FaceVertexCData',rgb,'EdgeColor','none', 'FaceAlpha', 0.5)
end
I promise I'll take a look at app properties, Chris.
But any suggestion how I could toggle back to the original plot?
Roger Breton
Roger Breton el 23 de Dic. de 2021
I'm looking at app properties now... It is exhausting EVERYTHING I have to swallow and learn in no time...
Thanks for your help and patience.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by