I need to chose between two images for postprocessing using uibuttongroup. Why is not working?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have two images as Option 1 and Option 2.
How to make it run and user be able to chose among the two images?
Is it correct How I call it?
Img = bg;
I use
bg = uibuttongroup('Visible','off',...
'Position',[0 0 .2 1],...
'SelectionChangeFcn',@Do_plot);
r1 = uicontrol(bg,'Style',...
'radiobutton',...
'String','Option 1',...
'Position',[10 350 100 30],...
'HandleVisibility','off');
r2 = uicontrol(bg,'Style','radiobutton',...
'String','Option 2',...
'Position',[10 250 100 30],...
'HandleVisibility','off');
% Make the uibuttongroup visible after creating child objects.
bg.Visible = 'on';
Img = bg; %% This is the crucial point where the chosen image goes for more postprocessing.
function Do_plot(hObject, event, varargin)
bg = findobj(gcf,sel);
sel = bg.SelectedObject;
if isempty(sel)
return; %no buttons selected
end
sel_string = sel.String;
switch sel_string
case 'Option 1'
bg = double(croppedImage);
case 'Option 2'
bg = double(J);
end
end
0 Commenti
Risposte (1)
Walter Roberson
il 3 Feb 2019
Img = bg;
would assign Img a copy of the handle to the button group. There is no numeric index or image associated with a button group.
You are trying to use callbacks as if they are functions that return values. The only kinds of callbacks that ever return values are the callbacks that act as position filters, such as a Position Constraint callback for an imroi. Callbacks for uicontrol, uipanel, axes, button groups, plots, surfaces, contour plots, patches: it is impossible for any of those to return a value. Likewise, graphics objects do not return values either. You can ask what the current state of a graphics object is.
Perhaps you need to read How To Share Variables in Callbacks
0 Commenti
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!