How to make an interactive panel for the user to chose among several options

4 views (last 30 days)
Hi
I want to have a panel (User Interface) with 3-4 different cropping image options and the user shall be able to chose the size he likes.
For instance, I could have subplot(2,2,1-4) four different cropping window sizes, of an image.
For example, a big cropping area of the image, a smaller one by 30%, an even smaller one by 50% of the original image, and a finally a very thin and slight strip of image.
By mouse clicking, the user can chose the appropriate cropping image window size for further processing.
Is it possible to do that?
Thanks

Accepted Answer

Walter Roberson
Walter Roberson on 2 Feb 2019
Yes. You could configure uicontrol style 'radio' in a uibuttongroup, or you could configure a single uicontrol style 'listbox' or 'popup' that had the four options configured.
  21 Comments
Stelios Fanourakis
Stelios Fanourakis on 9 Feb 2019
@Walter. Sorry but your last explanation is too much complicated for me to understand. Can you please explain it with fewer words?
Also, what is wrong with this code I use? I probably have limited knowledge on GUI and how they work. That's why I am here, so I can learn from my mistakes.
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 image I need to define whether Option1 = croppedImage, or Option2 = J; CroppedImage and J are two different images.
And the function Do_plot that follows in the end of the script.
function Do_plot(hObject, event, varargin)
bg = findobj(gcf, 'Tag', 'BG1');
sel = bg.SelectedObject;
if isempty(sel)
return; %no buttons selected
end
sel_string = sel.String;
switch sel_string
case 'Option 1'
bg.Value = croppedImage;
case 'Option 2'
bg.Value = J;
end
bg= double(bg);
end

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!