How can I check a specific axes has an image or not ?

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.

 Respuesta aceptada

you can get the 'Children' property of the axes.
axes_handle.Children
%or
get(axes_handle,'Children')

6 comentarios

findobj(axes_handle , 'type', 'image')
however it would probably make more sense to enable it when you put the image in
Thank you bro its working. I use this in app designer like this.
if ~isempty(get(app.UIaxis,'Children'))
set(app.pushbutton,'Enable','on');
end
That does not say that there is an image in the axes, just that there is something that is not in the axis that is not hidden.
May be you are right So, Have you any solution ?
if ~isempty(findobj(app.UIaxis.Children, 'type', 'flat', 'type', 'image'))
or
any(arrayfun(@(x)isa(x,'matlab.graphics.primitive.Image'),ax.Children))
Thank you very much.

Iniciar sesión para comentar.

Más respuestas (1)

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 comentarios

You are also right Thank you.
You're welcome. You can also than people by clicking the "Vote" link under their icon.
I'm done with it.
Thanks Again.

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 13 de En. de 2019

Comentada:

el 13 de En. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by