radiobutton to switch between scatter3 datasets?

조회 수: 1(최근 30일)
Roger Breton
Roger Breton 2021년 12월 23일
답변: Roger Breton 2021년 12월 23일
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
Roger Breton
Roger Breton 2021년 12월 23일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Breton
Roger Breton 2021년 12월 23일
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!

추가 답변(1개)

Cris LaPierre
Cris LaPierre 2021년 12월 23일
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
Roger Breton
Roger Breton 2021년 12월 23일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by