Add image (logo) to GUI and hide it with pushbutton

4 次查看(过去 30 天)
Dear all,
I would like to add a logo to my GUI and only display it when a check box is marked.
I add the logo by:
axes(handles.SmileG)
smileg=imread('logo.jpg');
image(smileg);
axis off
axis image
This works fine, but now i would like it to be removed / hidden when a box is marked. I know how to hide something with setting the visible to off/on.
Smile_Status = get(handles.Smile,'Value');
if Smile_Status == 1
set(handles.SmileG,'visible','on');
else
set(handles.SmileG,'visible','off');
end
The problem is that now the original axis, used to get the figure in the GUI hide / appear. I need to get the handle / add handle to the figure added instead.
Anyone has an idea?
Kind regards

采纳的回答

Jan
Jan 2017-10-1
Toggle the visibility of the image, not of the axes:
axes(handles.SmileG)
smileg=imread('logo.jpg');
handles.SmileLogo = image(smileg);
axis off
axis image
guidata(hObject, handles);
And in the callback of the checkbox:
function CheckboxCallback(hObject, EventData, handles)
Smile_Status = ;
if get(handles.Smile,'Value')
set(handles.SmileLogo, 'visible', 'on');
else
set(handles.SmileLogo, 'visible', 'off');
end

更多回答(1 个)

Image Analyst
Image Analyst 2017-10-1
Get a handle from image() or imshow(). Then try to set both handles (axes and image) visibility to off. If that doesn't work, try calling "cla reset" and then set the axes visibility to off, and to show again, set the visibility on and call image() again.

Community Treasure Hunt

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

Start Hunting!

Translated by