0

handles.axes画像が存在する場合と画像が存在しない場合、どの値が格納されますか? 画像が存在するかどうかの状態を確認したいので、これを実装しました

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

しかし、これは機能していません。これを行う最善の方法を教えてください。

4

1 に答える 1

1

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));
于 2013-04-27T15:38:30.467 に答える