Just a small modification to go please
Mostrar comentarios más antiguos
Hi
I have modified my code from previous times. I am so close to achieve what I want to achive but I know that I cannot surpass some minor obstacles. Can you please help me. I want to have the user being able to choose between two images.
I use that code.
S.bg = uibuttongroup(gcf,'Visible','off',...
'Position',[0 0 .2 1]);
S.r(1) = uicontrol(S.bg,'Style',...
'radiobutton',...
'String','Option 1',...
'Position',[10 350 100 30]);
S.r(2) = uicontrol(S.bg,'Style','radiobutton',...
'String','Option 2',...
'Position',[10 250 100 30]);
S.pb = uicontrol('style','push',...
'unit','pix',...
'position',[75 20 100 30],...
'string','Get Current Radio',...
'callback',{@pb_call,S});
handles.axes1 = subplot(1,2,1)
handles.axes2 = subplot(1,2,2)
guidata(handles.axes1,croppedImage);
guidata(handles.axes2,J);
Img = double(S.bg);
setappdata(gcf,'Img',Img);
ANd the callback function at the end
function [] = pb_call(varargin)
getappdata(gcf,'Img',Img);
% Callback for pushbutton.
S = varargin{3}; % Get the structure.
% Instead of switch, we could use num2str on:
% find(get(S.bg,'selectedobject')==S.rd) (or similar)
% Note the use of findobj. This is because of a BUG in MATLAB, whereby if
% the user selects the same button twice, the selectedobject property will
% not work correctly.
switch findobj(get(S.bg,'selectedobject'))
case S.rd(1)
set(S.ed,'string','1') % Set the editbox string.
Img = getimage(handles.axes1, croppedImage)
case S.rd(2)
set(S.ed,'string','2')
Img = getimage(handles.axes2, J)
otherwise
set(S.ed,'string','None!') % Very unlikely I think.
end
guidata(gcf,S,Img);
drawnow()
end
I get a black image and if I display the variable Img I get just a number
>> Img
Img =
2.0289306640625
So, what is wrong? Can you please help?
I am very close to achieve it. I can feel it, but, obviously I have a lack of some basics knowledge.
PLease, help!!!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!