handles.axes
画像が存在する場合と画像が存在しない場合、どの値が格納されますか? 画像が存在するかどうかの状態を確認したいので、これを実装しました
if handles.axes1==0
msgbox('Please insert image. . .', 'Error. . .');
end
しかし、これは機能していません。これを行う最善の方法を教えてください。
handles.axes
画像が存在する場合と画像が存在しない場合、どの値が格納されますか? 画像が存在するかどうかの状態を確認したいので、これを実装しました
if handles.axes1==0
msgbox('Please insert image. . .', 'Error. . .');
end
しかし、これは機能していません。これを行う最善の方法を教えてください。
Axes ハンドルは、への呼び出しによって変更されませimshow
ん。これは、Axes にイメージをプロットしますが、Axes のハンドルには何もしません。次の方法で、軸に何かが描画されているかどうかを確認できます。
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));