2013-04-27 4 views
0

이미지가 있고 이미지가없는 경우 어떤 값이 handles.axes에 저장됩니까? 나는 이미지 존재 여부 상태를 확인 원하고, 내가이핸들 값. MATLAB GUI의 축

if handles.axes1==0 
msgbox('Please insert image. . .', 'Error. . .'); 
end 

을 구현 그러나 이것은 나에게이 일을하는 가장 좋은 방법을 제안 해주십시오 작동하지 않습니다.

+0

당신은 어떻게 처음부터'handles.axes1'을 생성 않습니다 아무것도 가진 축에 그려되어 있는지 확인할 수 있습니까? – Oleg

+0

'axes (handles.axes1); imshow (fname); ' – Chethan

+0

[axes] (http://www.mathworks.com/help/matlab/ref/axes.html) 그래픽 개체와 [image] (http : // www. mathworks.com/help/matlab/ref/image.html) 개체. 또한 핸들이 유효한지 테스트하기 위해'ishghandle'을 사용하십시오 – Amro

답변

1

imshow에 대한 호출로 축 핸들이 수정되지 않습니다.이 축 처리는 축에 이미지를 표시하지만 축의 핸들에는 적용되지 않습니다.

cs = get(handles.axes1, 'Children'); 
if isempty(cs) 
    % Nothing in axes 
else 
    % Something has been drawn in the axes 

    if any(strcmp(get(cs, 'Type'), 'image')) 
     % An image has been drawn in the axes 
    end 
end 

또한 같은 효과에 findobj을 사용할 수,

hasImage = ~isempty(findobj('Type', 'image', 'Parent', handles.axes1));