Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
Stijn Hillenius
Stijn Hillenius el 1 de Oct. de 2017
Comentada: Stijn Hillenius el 1 de Oct. de 2017
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

Respuesta aceptada

Jan
Jan el 1 de Oct. de 2017
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

Más respuestas (1)

Image Analyst
Image Analyst el 1 de Oct. de 2017
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