Thread Subject: Instantiation of multiple images in a GUI

Subject: Instantiation of multiple images in a GUI

From: Thiago Jota

Date: 19 Nov, 2008 17:43:02

Message: 1 of 5

I'm trying to instantiate an unique image within each axes object of my GUI. Unfortunately, this becomes problematic after the first image. I am using imread and imshow in the callback of each axes object. Is there any alternative?

Thanks

Subject: Instantiation of multiple images in a GUI

From: ImageAnalyst

Date: 19 Nov, 2008 18:48:30

Message: 2 of 5

On Nov 19, 12:43=A0pm, "Thiago Jota" <thi...@mathworks.com> wrote:
> I'm trying to instantiate an unique image within each axes object of my G=
UI. Unfortunately, this becomes problematic after the first image. I am usi=
ng imread and imshow in the callback of each axes object. Is there any alte=
rnative?
>
> Thanks

---------------------------------------------------------------------------=
---------------------------
Thiago Jota:
Don't load images into the axes in the callback of the axes. You can
do it in the callback of your listbox or some other function. You
click on an image filename in your listbox, or set it in your function
somehow. Then in the call back of the listbox, or in that other
function, you can call imread and imshow. Before you call those
however, make sure you call the axes function and pass it the handle
to the axes where you want the image displayed.

Clicking on an axes is problematic because once an image is thrown
into it, I think it essentially lies on top of the axes and you can
never click on the axes again because it's underneath the image -
you're clicking on the image which is a child of the axes and you'd
have to set up a callback for that image which is separate from the
callback of the axes that it lives in. Really quirky, I know.
Regards,
ImageAnalyst

Subject: Instantiation of multiple images in a GUI

From: Thiago

Date: 19 Nov, 2008 20:54:02

Message: 3 of 5

I've found a solution! After creating axes objects in GUIDE, place this code inside each "axes_CreateFcn" callback:

axes(hObject)
imshow('file.extension');
title('')

I am able to instantiate multiple images in the same figure with this technique, which originated from this tutorial by Doug Hull:

http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-background-image-for-a-gui/

Subject: Instantiation of multiple images in a GUI

From: ImageAnalyst

Date: 19 Nov, 2008 21:14:27

Message: 4 of 5

On Nov 19, 3:54=A0pm, "Thiago " <thi...@mathworks.com> wrote:
> I've found a solution! After creating axes objects in GUIDE, place this c=
ode inside each "axes_CreateFcn" callback:
>
> axes(hObject)
> imshow('file.extension');
> title('')
>
> I am able to instantiate multiple images in the same figure with this tec=
hnique, which originated from this tutorial by Doug Hull:
>
> http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-ba...

-------------------------------------------------------------------
Yes, most of the time you need to call the axes command to set the
current graphics object (the "gca") to the one you want to put stuff
into before you put the stuff in. So that's why it worked for you.
It's a bit puzzling though. You'd think that inside the creation
callback for the axes, that the gca would already be that axes, but
maybe not. In other words I'm surprised you had to do that because
you'd think that that would have already been done automatically
without you having to explicitly do it. Maybe that doesn't occur
until the creation callback completely terminates. But if that were
the case, (the axes weren't yet full created) then how could you issue
an axes() command to it?

Subject: Instantiation of multiple images in a GUI

From: Thiago

Date: 19 Nov, 2008 21:27:02

Message: 5 of 5

The tutorial I cited explains why.

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <236663b5-3953-416e-a6d9-256634da7feb@g38g2000yqd.googlegroups.com>...
> On Nov 19, 3:54=A0pm, "Thiago " <thi...@mathworks.com> wrote:
> > I've found a solution! After creating axes objects in GUIDE, place this c=
> ode inside each "axes_CreateFcn" callback:
> >
> > axes(hObject)
> > imshow('file.extension');
> > title('')
> >
> > I am able to instantiate multiple images in the same figure with this tec=
> hnique, which originated from this tutorial by Doug Hull:
> >
> > http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-ba...
>
> -------------------------------------------------------------------
> Yes, most of the time you need to call the axes command to set the
> current graphics object (the "gca") to the one you want to put stuff
> into before you put the stuff in. So that's why it worked for you.
> It's a bit puzzling though. You'd think that inside the creation
> callback for the axes, that the gca would already be that axes, but
> maybe not. In other words I'm surprised you had to do that because
> you'd think that that would have already been done automatically
> without you having to explicitly do it. Maybe that doesn't occur
> until the creation callback completely terminates. But if that were
> the case, (the axes weren't yet full created) then how could you issue
> an axes() command to it?

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com