Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
problem in getting point coordinates in gui

Subject: problem in getting point coordinates in gui

From: shailesh gupta

Date: 14 Dec, 2008 14:11:41

Message: 1 of 3

Hi
I am trying to make a Gui in which i load image in axes. User has to
click anywhere in the image and i have to know where he clicked. i.e I
want to get co-ordinates of the point of mouse-click.
I tried it out. I am getting points without image i.e. on blank axes.
But with image, nothing happens..
Can anyone help me out with what to do..

thanking in advance...

Subject: problem in getting point coordinates in gui

From: Dave Brackett

Date: 14 Dec, 2008 16:47:02

Message: 2 of 3

shailesh gupta <sha.gupta.88@gmail.com> wrote in message <7613d61e-d2a3-4f28-95be-428eb314332a@w24g2000prd.googlegroups.com>...
> Hi
> I am trying to make a Gui in which i load image in axes. User has to
> click anywhere in the image and i have to know where he clicked. i.e I
> want to get co-ordinates of the point of mouse-click.
> I tried it out. I am getting points without image i.e. on blank axes.
> But with image, nothing happens..
> Can anyone help me out with what to do..
>
> thanking in advance...

It works fine for me. Check that your code is similar to this:

h=imread('image_file.jpg');
figure
image(h)
[x,y]=ginput(5)

where 5 is the number of points. if you use ginput you can take unlimited points, but the user has to press enter after the last point. also note, that you won't get the coordinates until all of the points have been taken (as far as I'm aware).

Subject: problem in getting point coordinates in gui

From: Dave Brackett

Date: 14 Dec, 2008 16:58:03

Message: 3 of 3

"Dave Brackett" <davebrackett@hotmail.com> wrote in message <gi3da6$ig9$1@fred.mathworks.com>...
> shailesh gupta <sha.gupta.88@gmail.com> wrote in message <7613d61e-d2a3-4f28-95be-428eb314332a@w24g2000prd.googlegroups.com>...
> > Hi
> > I am trying to make a Gui in which i load image in axes. User has to
> > click anywhere in the image and i have to know where he clicked. i.e I
> > want to get co-ordinates of the point of mouse-click.
> > I tried it out. I am getting points without image i.e. on blank axes.
> > But with image, nothing happens..
> > Can anyone help me out with what to do..
> >
> > thanking in advance...
>
> It works fine for me. Check that your code is similar to this:
>
> h=imread('image_file.jpg');
> figure
> image(h)
> [x,y]=ginput(5)
>
> where 5 is the number of points. if you use ginput you can take unlimited points, but the user has to press enter after the last point. also note, that you won't get the coordinates until all of the points have been taken (as far as I'm aware).


sorry just realised that you wanted it in a GUI. it is basically the same, but replaces 'figure' in the second line with 'axes(handles.axes1)' or whatever your axes tag is.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us