Thread Subject: image pricessing- location of selected point

Subject: image pricessing- location of selected point

From: tomer flo

Date: 11 Nov, 2009 21:26:05

Message: 1 of 11

Hi,
I have an image and the user has to click anywhere and select a point by mouse-clicking. I want to get the co-ordinates of the selected point.
I am using the "impoint" function however I can't get the co-ordinates of the point...
I am trying to get the co-ordinates by using the "getPositiong" however it doen't work
Can anyone help me out with what to do..
the code is attached...

figure, imshow('pout.tif');
h1 = impoint(gca, []);
pos = getPosition(h1);

thanking in advance!

Subject: image pricessing- location of selected point

From: ImageAnalyst

Date: 11 Nov, 2009 21:33:59

Message: 2 of 11

On Nov 11, 4:26 pm, "tomer flo" <tomer...@yahoo.com> wrote:
> Hi,
> I have an image and the user has to click anywhere and select a point by mouse-clicking. I want to get the co-ordinates of the selected point.
> I am using the "impoint" function however I can't get the co-ordinates of the point...
> I am trying to get the co-ordinates by using the "getPositiong" however it doen't work
> Can anyone help me out with what to do..
> the code is attached...
>
> figure, imshow('pout.tif');
> h1 = impoint(gca, []);
> pos = getPosition(h1);
>
> thanking in advance!

-----------------------------------------------------------------------------------------------------------------
Maybe you'd prefer ginput() instead.

Subject: image pricessing- location of selected point

From: tomer flo

Date: 11 Nov, 2009 21:41:17

Message: 3 of 11

but with ginput() I can't let the user the change the position of the selected point...
>
> -----------------------------------------------------------------------------------------------------------------
> Maybe you'd prefer ginput() instead.

Subject: image pricessing- location of selected point

From: ImageAnalyst

Date: 11 Nov, 2009 23:15:15

Message: 4 of 11

On Nov 11, 4:41 pm, "tomer flo" <tomer...@yahoo.com> wrote:
> but with ginput() I can't let the user the change the position of the selected point...
>
 
---------------------------------------------------------------------------­--------------------------------------
I'm not sure what you want. If you expect the user to select a point,
and then change their mind and want to select a different location
then you can put it into a while loop and just call ginput() followed
by a call to questdlg with the prompt "Are you finally done selecting
the position of your point?" When they answer "yes" you exit the loop
otherwise it will go through the loop again calling ginput().

Or just have a push button that says "Specify point location" or
something like that. In the button callback, you simply have a call
to ginput. If they change their mind, they simply click the
pushbutton again.

Subject: image pricessing- location of selected point

From: aviv

Date: 12 Nov, 2009 08:12:03

Message: 5 of 11


> ---------------------------------------------------------------------------?--------------------------------------
> I'm not sure what you want. If you expect the user to select a point,
> and then change their mind and want to select a different location
> then you can put it into a while loop and just call ginput() followed
> by a call to questdlg with the prompt "Are you finally done selecting
> the position of your point?" When they answer "yes" you exit the loop
> otherwise it will go through the loop again calling ginput().
>
> Or just have a push button that says "Specify point location" or
> something like that. In the button callback, you simply have a call
> to ginput. If they change their mind, they simply click the
> pushbutton again.

thank you very much for your help but I am not sure ginput() is the answer cause the process sould be interactive with the user. the user has to select a few points and be able to change their position till he reaches the desired one. with ginput() I can't see the lacation of the selected point on the image and can't change it.
with impoint() I can select a point and drag it on the image however for some reason I can't get the position of it. it says that I can use the getPosition() in order to get the co-ordinates but it doesn't work for me. I need the co-ordinates of the points for later use.

thanks again for your help!

Subject: image pricessing- location of selected point

From: ImageAnalyst

Date: 12 Nov, 2009 13:10:50

Message: 6 of 11

aviv and tomer:
I don't think you can have a bunch of draggable points all up there at
the same time. At least I couldn't figure out how to do it.
If you need to do that I suggest you use roipoly(). It will give you
draggability of all the points. When you are finished positioning the
points, create the mask by double-clicking, or by right-clicking
inside the region and selecting Create mask from the context menu. It
will then return all the coordinates of all the vertices. The only
drawback is that you will have lines in between ordered points. But
if you can live with that then this will do the job easily.
Regards,
ImageAnalyst

Subject: image pricessing- location of selected point

From: ImageAnalyst

Date: 12 Nov, 2009 15:25:02

Message: 7 of 11

Another option you may want to look at is cpselect().

Subject: image pricessing- location of selected point

From: aviv

Date: 12 Nov, 2009 22:06:01

Message: 8 of 11

thank you very much!!!
we will try both ways and hopefully it'll work...

best regarts,
Tomer & Aviv

Subject: image pricessing- location of selected point

From: Eric

Date: 11 Jan, 2010 22:22:20

Message: 9 of 11

I'm having the same problem. cpselect is designed for two images, but I'd really like to define points on just one. I tried using

[xy1, xy2] = cpselect(W_L.Map, zeros(10,10),'Wait',true)

but xy1 and xy2 are both empty unless I select points on both of the images in cpselect (i.e., the desired one and the "black" one I passed it). I could select meaningless points on the 10x10 zeros matrix, but I'm developing a tool others will use and want to avoid anything so kludgy.

The other thing I've done previously for creating multiple, draggable points on a single image is to create multiple datatips and then get their locations when a button in a GUI is clicked. This isn't going to work well for what I'm working on now, either.

I guess I'll put in a request for cpselect() to function on just a single image rather than a pair. This would make it more useful when more than two images are to be registered.

-Eric

Subject: image pricessing- location of selected point

From: Alex Taylor

Date: 14 Jan, 2010 21:59:05

Message: 10 of 11

"tomer flo" <tomer_fl@yahoo.com> wrote in message <hdfa5d$3f2$1@fred.mathworks.com>...
> Hi,
> I have an image and the user has to click anywhere and select a point by mouse-clicking. I want to get the co-ordinates of the selected point.
> I am using the "impoint" function however I can't get the co-ordinates of the point...
> I am trying to get the co-ordinates by using the "getPositiong" however it doen't work
> Can anyone help me out with what to do..
> the code is attached...
>
> figure, imshow('pout.tif');
> h1 = impoint(gca, []);
> pos = getPosition(h1);
>
> thanking in advance!

Tomer,

The code segment above will work in MATLAB versions 8a and later. In prior versions, there is an extra step required to access the impoint API.

Try executing the following:

figure; imshow('pout.tif');
hpoint = impoint(gca,10,100);
api = iptgetapi(hpoint);
api.getPosition();

Hope this helps,

Alex.

Subject: image pricessing- location of selected point

From: Michael

Date: 3 Feb, 2010 13:21:05

Message: 11 of 11

"Alex Taylor" <iamanonster@gmail.com> wrote in message <hio439$l3r$1@fred.mathworks.com>...
> "tomer flo" <tomer_fl@yahoo.com> wrote in message <hdfa5d$3f2$1@fred.mathworks.com>...
> > Hi,
> > I have an image and the user has to click anywhere and select a point by mouse-clicking. I want to get the co-ordinates of the selected point.
> > I am using the "impoint" function however I can't get the co-ordinates of the point...
> > I am trying to get the co-ordinates by using the "getPositiong" however it doen't work
> > Can anyone help me out with what to do..
> > the code is attached...
> >
> > figure, imshow('pout.tif');
> > h1 = impoint(gca, []);
> > pos = getPosition(h1);
> >
> > thanking in advance!
>
> Tomer,
>
> The code segment above will work in MATLAB versions 8a and later. In prior versions, there is an extra step required to access the impoint API.
>
> Try executing the following:
>
> figure; imshow('pout.tif');
> hpoint = impoint(gca,10,100);
> api = iptgetapi(hpoint);
> api.getPosition();
>
> Hope this helps,
>
> Alex.


I'm not sure if this thread was ever solved, but I'm doing a similar thing. The way I produce the points on my image is to get the current point of the image axes, then set the impoint from that:

currentPoint = get(handles.imageAxes, 'CurrentPoint');
thePoint = impoint(gca,currentPoint(1), currentPoint(3));

Put this in a buttonDownFcn that you attach to the image handle and you'll be all set. If you don't display an image on the axes you can attach the buttonDownFcn directly to the axes. Otherwise do:

handles.imageHandle = imshow(displayImage);
set(handles.imageHandle, 'ButtonDownFcn', {@image_ButtonDownFcn, handles});

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
image buttondow... Michael 3 Feb, 2010 08:24:17
impoint iptgetapi Alex Taylor 14 Jan, 2010 16:59:12
coordinate points Mathew Thomas 12 Nov, 2009 09:05:17
mouse tomer flo 11 Nov, 2009 16:29:23
coordinated tomer flo 11 Nov, 2009 16:29:23
location tomer flo 11 Nov, 2009 16:29:23
image tomer flo 11 Nov, 2009 16:29:23
rssFeed for this Thread

Contact us at files@mathworks.com