Got Questions? Get Answers.
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:
polygons

Subject: polygons

From: Jessica

Date: 21 Mar, 2008 00:26:02

Message: 1 of 6

Hi,

I have a list of x and y coordinates that specifies a
polygon which lies within an image. I was wondering whether
it is possible to open up the image, overlay the polygon on
top of it, move the polygon to a different position on the
image, and then output the new xy coordinates of the
polygon.

Thanks,
Jessica

Subject: polygons

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 21 Mar, 2008 13:15:35

Message: 2 of 6

In article <fruvaq$kok$1@fred.mathworks.com>,
Jessica <jyorzinski@ucdavis.edu> wrote:

>I have a list of x and y coordinates that specifies a
>polygon which lies within an image. I was wondering whether
>it is possible to open up the image, overlay the polygon on
>top of it, move the polygon to a different position on the
>image, and then output the new xy coordinates of the
>polygon.

Could you clarify what you mean by "open up the image"?

At the moment I am not sure what difference there would be
between the process you indicate, compared to simply
adding constant offsets to the polygon x and y coordinates
and outputting the result? What does the image contribute
to the process?
--
  "If there were no falsehood in the world, there would be no
  doubt; if there were no doubt, there would be no inquiry; if no
  inquiry, no wisdom, no knowledge, no genius."
                                              -- Walter Savage Landor

Subject: polygons

From: Jessica

Date: 21 Mar, 2008 13:36:01

Message: 3 of 6

Thanks for looking over this question. I would like to open
up an image because I have a polygon tracing the outline of
a certain object in the image. I want to be able to see the
image so that I can move the polygon atop a different
object in the image. (I can't just add a constant because I
don't know exactly where I want to move the polygon without
looking at the image).


"Jessica " <jyorzinski@ucdavis.edu> wrote in message
<fruvaq$kok$1@fred.mathworks.com>...
> Hi,
>
> I have a list of x and y coordinates that specifies a
> polygon which lies within an image. I was wondering
whether
> it is possible to open up the image, overlay the polygon
on
> top of it, move the polygon to a different position on
the
> image, and then output the new xy coordinates of the
> polygon.
>
> Thanks,
> Jessica

Subject: polygons

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 21 Mar, 2008 13:44:26

Message: 4 of 6

In article <fs0dk1$lvn$1@fred.mathworks.com>,
Jessica <jyorzinski@ucdavis.edu> wrote:
>Thanks for looking over this question. I would like to open
>up an image because I have a polygon tracing the outline of
>a certain object in the image. I want to be able to see the
>image so that I can move the polygon atop a different
>object in the image. (I can't just add a constant because I
>don't know exactly where I want to move the polygon without
>looking at the image).

In that case, you can use image() or imshow() to display
the image, and you can use line() to draw the polygon on top
of it. (Watch out for whether the coordinates start from
the top left or the bottom left.) Moving the polygon could
then be programmed through callbacks.
--
  "Allegories are in the realm of thoughts, what ruins are in
  the realm of things." -- Walter Benjamin

Subject: polygons

From: Randy Poe

Date: 21 Mar, 2008 14:16:24

Message: 5 of 6

Please don't top-post, it garbles the discussion.

On Mar 21, 9:36 am, "Jessica " <jyorzin...@ucdavis.edu> wrote:
> "Jessica " <jyorzin...@ucdavis.edu> wrote in message
>
> <fruvaq$ko...@fred.mathworks.com>...
>
> > Hi,
>
> > I have a list of x and y coordinates that specifies a
> > polygon which lies within an image. I was wondering
> whether
> > it is possible to open up the image, overlay the polygon
> on
> > top of it, move the polygon to a different position on
> the
> > image, and then output the new xy coordinates of the
> > polygon.
>
> > Thanks,
> > Jessica
> Thanks for looking over this question. I would like to open
> up an image because I have a polygon tracing the outline of
> a certain object in the image. I want to be able to see the
> image so that I can move the polygon atop a different
> object in the image. (I can't just add a constant because I
> don't know exactly where I want to move the polygon without
> looking at the image).

As Walter said, you will want to do this with callbacks.

It sounds like what you want is to be able to have
the user click on your polygon and drag it around,
or perhaps position it with arrow keys. Let's talk
about dragging.

You want to detect when the user clicks inside
the polygon. You can detect the click event, and
then check the (x,y) position of the cursor with
a call (INPOLYGON, I think).

Now as the mouse is moved, you can track the
new (x,y) position. To "drag" the polygon, you're
going to have to do something like figure out the
offset of the mouse from the original position,
and then offset every vertex of the polygon by the
same shift in x and y.

So in order to do that, you'll already have the
information you asked about. As soon as the user
stops dragging, return your final offset or final
polygon vertices.

So now the question is how to implement these operations.
I'll take a few minutes and see if I can identify the
right function calls and callbacks, or perhaps somebody
else might chime in before I get a chance to post
my followup.

               - Randy

Subject: polygons

From: Jessica

Date: 22 Mar, 2008 00:04:03

Message: 6 of 6

Randy Poe <poespam-trap@yahoo.com> wrote in message
<9f9a904e-0896-4188-93bd-
20e7bcd38dae@f63g2000hsf.googlegroups.com>...
> Please don't top-post, it garbles the discussion.
>
> On Mar 21, 9:36 am, "Jessica " <jyorzin...@ucdavis.edu>
wrote:
> > "Jessica " <jyorzin...@ucdavis.edu> wrote in message
> >
> > <fruvaq$ko...@fred.mathworks.com>...
> >
> > > Hi,
> >
> > > I have a list of x and y coordinates that specifies a
> > > polygon which lies within an image. I was wondering
> > whether
> > > it is possible to open up the image, overlay the
polygon
> > on
> > > top of it, move the polygon to a different position on
> > the
> > > image, and then output the new xy coordinates of the
> > > polygon.
> >
> > > Thanks,
> > > Jessica
> > Thanks for looking over this question. I would like to
open
> > up an image because I have a polygon tracing the
outline of
> > a certain object in the image. I want to be able to see
the
> > image so that I can move the polygon atop a different
> > object in the image. (I can't just add a constant
because I
> > don't know exactly where I want to move the polygon
without
> > looking at the image).
>
> As Walter said, you will want to do this with callbacks.
>
> It sounds like what you want is to be able to have
> the user click on your polygon and drag it around,
> or perhaps position it with arrow keys. Let's talk
> about dragging.
>
> You want to detect when the user clicks inside
> the polygon. You can detect the click event, and
> then check the (x,y) position of the cursor with
> a call (INPOLYGON, I think).
>
> Now as the mouse is moved, you can track the
> new (x,y) position. To "drag" the polygon, you're
> going to have to do something like figure out the
> offset of the mouse from the original position,
> and then offset every vertex of the polygon by the
> same shift in x and y.
>
> So in order to do that, you'll already have the
> information you asked about. As soon as the user
> stops dragging, return your final offset or final
> polygon vertices.
>
> So now the question is how to implement these operations.
> I'll take a few minutes and see if I can identify the
> right function calls and callbacks, or perhaps somebody
> else might chime in before I get a chance to post
> my followup.
>
> - Randy

Thanks for everyone's suggestions. It seems that I will be
able to use the imdistline callback to determine the
distance I want to move the polygon. This will give me the
distance between two points that are draggable (same as the
example 1 listed in the help file). Unfortunately, it seems
that the only way to export the distance is to right-click
the image and tell it to export the clip but it should work
well enough (even if a little tedious).

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