How can I check a specific axes has an image or not ?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using app designer in Matlab 2018a and I replaces a button for testing which is disable.
I know how to enable it but I want to enable it when I have an image on axis.
댓글 수: 0
채택된 답변
Kevin Phung
2019년 1월 13일
you can get the 'Children' property of the axes.
axes_handle.Children
%or
get(axes_handle,'Children')
댓글 수: 6
Walter Roberson
2019년 1월 13일
if ~isempty(findobj(app.UIaxis.Children, 'type', 'flat', 'type', 'image'))
or
any(arrayfun(@(x)isa(x,'matlab.graphics.primitive.Image'),ax.Children))
추가 답변 (1개)
Image Analyst
2019년 1월 13일
What you accepted as the answer is really not the answer as Walter explained. You can use getimage() and check for zero-sized image. Here's a demo:
% Have either plot() or imshow() - comment out one of them.
% Put something into an axes that is NOT an image.
% plot(1:10)
% Put something into an axes that IS an image.
imshow('moon.tif')
% Check what's in the axes.
theImage = getimage();
whos theImage
if size(theImage, 1) ~= 0
msgbox('There is an image in there');
else
msgbox('There is no image in there');
end
댓글 수: 3
Image Analyst
2019년 1월 13일
You're welcome. You can also than people by clicking the "Vote" link under their icon.
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!