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

조회 수: 3 (최근 30일)
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

채택된 답변

Walter Roberson
Walter Roberson 2019년 2월 2일
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
Stelios Fanourakis
Stelios Fanourakis 2019년 2월 9일
@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

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by