필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Stijn Hillenius
Stijn Hillenius 2017년 10월 1일
댓글: Stijn Hillenius 2017년 10월 1일
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