Thread Subject: passing images between two GUI

Subject: passing images between two GUI

From: Dina

Date: 8 Aug, 2008 22:23:01

Message: 1 of 8


i'm working on an ocr software , and i have 2 GUI's one for
the manual character training, and one for the main program
, the thing is .. i made this pushbutton in the main program
GUI, that if the user wanted to train a certain character on
this GUI it select it and send it to the other trainer GUI,
i know how to select a part of the image .. i just dunno how
to pass it to the other GUI.. can anyone help plz?

also does any one know how to read directly from the scanner?

Subject: passing images between two GUI

From: bogfrog

Date: 8 Aug, 2008 23:04:38

Message: 2 of 8

>
> i'm working on an ocr software , and i have 2 GUI's
> one for
> the manual character training, and one for the main
> program
> , the thing is .. i made this pushbutton in the main
> program
> GUI, that if the user wanted to train a certain
> character on
> this GUI it select it and send it to the other
> trainer GUI,
> i know how to select a part of the image .. i just
> dunno how
> to pass it to the other GUI.. can anyone help plz?

You might want to take a look at this video:

http://blogs.mathworks.com/pick/2005/10/03/guide-video-part-two/

That's the way I do stuff like this. Maybe someone else knows of better ways?

Subject: passing images between two GUI

From: Dina

Date: 9 Aug, 2008 00:00:20

Message: 3 of 8

bogfrog <jmcgraw@rcn.com> wrote in message
<24866908.1218236727917.JavaMail.jakarta@nitrogen.mathforum.org>...
> >
> > i'm working on an ocr software , and i have 2 GUI's
> > one for
> > the manual character training, and one for the main
> > program
> > , the thing is .. i made this pushbutton in the main
> > program
> > GUI, that if the user wanted to train a certain
> > character on
> > this GUI it select it and send it to the other
> > trainer GUI,
> > i know how to select a part of the image .. i just
> > dunno how
> > to pass it to the other GUI.. can anyone help plz?
>
> You might want to take a look at this video:
>
>
http://blogs.mathworks.com/pick/2005/10/03/guide-video-part-two/
>
> That's the way I do stuff like this. Maybe someone else
knows of better ways?


i watched this video .. i just dunno how to apply that on
axes .. i'm a matlab newbie

but thanx anyway

Subject: passing images between two GUI

From: bogfrog

Date: 9 Aug, 2008 00:27:56

Message: 4 of 8

> i watched this video .. i just dunno how to apply
> that on
> axes .. i'm a matlab newbie
>
> but thanx anyway

Well what you should take away, is that you can store your data using setappata() and then get it anywhere else using the handle to where it is stored. So, you might have this in the _opening function_ of your main gui:

setappdata(0,'hMainGui',gcf); %note: gcf gets the handle

then, once you load up your image elsewhere in your code, you can do this:

setappdata(hMainGui,'myImage',imageMatrix);

then inside the functions for your _other_ gui, you do this:

hMainGui = getappdata(0,'hMainGui');
imageMatrix = getappdata(hMainGui,'myImage');

and you will have access to the image in your new gui.

Subject: passing images between two GUI

From: Dina

Date: 9 Aug, 2008 01:14:01

Message: 5 of 8

bogfrog <jmcgraw@rcn.com> wrote in message
<21579291.1218241707359.JavaMail.jakarta@nitrogen.mathforum.org>...
> > i watched this video .. i just dunno how to apply
> > that on
> > axes .. i'm a matlab newbie
> >
> > but thanx anyway
>
> Well what you should take away, is that you can store your
data using setappata() and then get it anywhere else using
the handle to where it is stored. So, you might have this
in the _opening function_ of your main gui:
>
> setappdata(0,'hMainGui',gcf); %note: gcf gets the handle
>
> then, once you load up your image elsewhere in your code,
you can do this:
>
> setappdata(hMainGui,'myImage',imageMatrix);
>
> then inside the functions for your _other_ gui, you do this:
>
> hMainGui = getappdata(0,'hMainGui');
> imageMatrix = getappdata(hMainGui,'myImage');
>
> and you will have access to the image in your new gui.


it gives me this error

 Undefined function or variable 'hMainGui'.

Error in ==> Main>Main_OpeningFcn at 56
setappdata(hMainGui,'C',imageMatrix);

Error in ==> gui_mainfcn at 210
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [],
guidata(gui_hFigure), varargin{:});

Error in ==> Main at 42
    gui_mainfcn(gui_State, varargin{:});

>>

i would really appreciate it if u gave me more details ..
like what should i write in the pushbutton callback?


thanks alot

Subject: passing images between two GUI

From: bogfrog

Date: 9 Aug, 2008 03:53:44

Message: 6 of 8

> it gives me this error
>
> Undefined function or variable 'hMainGui'.
>
> Error in ==> Main>Main_OpeningFcn at 56
> setappdata(hMainGui,'C',imageMatrix);

If you are in your main opening function, for the main gui, before that line (where you get the error), you should have:

setappdata(0,'hMainGui',gcf)
hMainGui = getappdata(0,'hMainGui')

then you can do

setappdata(hMainGui,'C',imageMatrix);


See, '0' is the handle to the root workspace. So in the first line above, I save the gui handle (gotten by gcf) to a application datum I call "hMainGui" stored in the root workspace. Then I get it from the root (2nd line) and assign it to a variable called hMainGui. Now the hMainGui handle is defined.


> i would really appreciate it if u gave me more
> details ..
> like what should i write in the pushbutton callback?

that depends on what you want the pushbutton to do. I'm not familiar enough with what you're doing to answer. But if you want to access the image data, assuming you build on the same code as above, you would do this:

hMainGui = getappdata(0,'hMainGui');
image = getappdata(hMainGui,'C')

now the image should be stored in 'image'

Subject: passing images between two GUI

From: bogfrog

Date: 9 Aug, 2008 08:26:19

Message: 7 of 8

You know what... you actually can pass to a gui, in the same way you do to a function.

In the opening function of the gui, do this:

handles.input1 = varargin{1};


and then elsewhere in this gui, the variable you passed will be in handles.input.

Subject: passing images between two GUI

From: Dina

Date: 11 Aug, 2008 02:50:03

Message: 8 of 8

bogfrog <jmcgraw@rcn.com> wrote in message
<6587715.1218270409944.JavaMail.jakarta@nitrogen.mathforum.o
rg>...
> You know what... you actually can pass to a gui, in the
same way you do to a function.
>
> In the opening function of the gui, do this:
>
> handles.input1 = varargin{1};
>
>
> and then elsewhere in this gui, the variable you passed
will be in handles.input.

thank u

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
images Dina 8 Aug, 2008 18:25:04
passing Dina 8 Aug, 2008 18:25:03
gui Dina 8 Aug, 2008 18:25:03
ocr Dina 8 Aug, 2008 18:25:03
rssFeed for this Thread

Contact us at files@mathworks.com