Thread Subject: Organise or sort 2d coordinates?

Subject: Organise or sort 2d coordinates?

From: Sven

Date: 11 Nov, 2009 04:20:18

Message: 1 of 3

Hi all,

Has anyone produced a function that can help me sort a set of 2d points in a 'somewhat geometrically ordered' way?

The above is in quotation marks because I understand that if my points don't provide a convex hull, the problem of ordering them (without further info) is itself ill-defined.
Nevertheless, if you were to take the boundary points of some shape and then randomize those points, I think you could approximate the ordering that would return your closed contour using perhaps a combination of polar coordinates and nearest-neighbour computations.

My thoughts would be to centre the points near zero, then sort via their polar coordinates. From these sorted points, find a 'stable' location where the tangent to the points is least noisy. Start from this location, and try and use nearest-neighbour calculations to skip from one point to the next until you come back around to your starting point.

So my question is: has anyone tackled this problem and come up with something workable yet? My searches through the file exchange are at the moment coming up empty.

If there's truly nothing there, I'll take a shot at it for the kinds of shapes I'm trying to get a contour around, and maybe it can be generalised enough to stick up on the file exchange when it's done.

Cheers,
Sven.

Subject: Organise or sort 2d coordinates?

From: ImageAnalyst

Date: 11 Nov, 2009 04:30:45

Message: 2 of 3

On Nov 10, 11:20 pm, "Sven" <sven.holco...@gmail.deleteme.com> wrote:
> Hi all,
>
> Has anyone produced a function that can help me sort a set of 2d points in a 'somewhat geometrically ordered' way?
>
> The above is in quotation marks because I understand that if my points don't provide a convex hull, the problem of ordering them (without further info) is itself ill-defined.
> Nevertheless, if you were to take the boundary points of some shape and then randomize those points, I think you could approximate the ordering that would return your closed contour using perhaps a combination of polar coordinates and nearest-neighbour computations.
>
> My thoughts would be to centre the points near zero, then sort via their polar coordinates. From these sorted points, find a 'stable' location where the tangent to the points is least noisy. Start from this location, and try and use nearest-neighbour calculations to skip from one point to the next until you come back around to your starting point.
>
> So my question is: has anyone tackled this problem and come up with something workable yet? My searches through the file exchange are at the moment coming up empty.
>
> If there's truly nothing there, I'll take a shot at it for the kinds of shapes I'm trying to get a contour around, and maybe it can be generalised enough to stick up on the file exchange when it's done.
>
> Cheers,
> Sven.

--------------------------------------------------------------------------
It might depend on how scattered they are. If it looks like a shotgun
pattern, then it might be tough to pick any kind of order. If it's
basically some kind of somwhat noisy path around a well defined
perimeter of some shape, you might have a good algorithm. That's why
it would be nice to see an example.

John D'Errico posted a nice fitting routine here:
http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
Not sure if it works on closed contours though.

Subject: Organise or sort 2d coordinates?

From: Matt Fetterman

Date: 11 Nov, 2009 04:48:01

Message: 3 of 3

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <447cd29d-3596-4d86-9820-f03d5a413231@v37g2000vbb.googlegroups.com>...
> On Nov 10, 11:20?pm, "Sven" <sven.holco...@gmail.deleteme.com> wrote:
> > Hi all,
> >
> > Has anyone produced a function that can help me sort a set of 2d points in a 'somewhat geometrically ordered' way?
> >
> > The above is in quotation marks because I understand that if my points don't provide a convex hull, the problem of ordering them (without further info) is itself ill-defined.
> > Nevertheless, if you were to take the boundary points of some shape and then randomize those points, I think you could approximate the ordering that would return your closed contour using perhaps a combination of polar coordinates and nearest-neighbour computations.
> >
> > My thoughts would be to centre the points near zero, then sort via their polar coordinates. From these sorted points, find a 'stable' location where the tangent to the points is least noisy. Start from this location, and try and use nearest-neighbour calculations to skip from one point to the next until you come back around to your starting point.
> >
> > So my question is: has anyone tackled this problem and come up with something workable yet? My searches through the file exchange are at the moment coming up empty.
> >
> > If there's truly nothing there, I'll take a shot at it for the kinds of shapes I'm trying to get a contour around, and maybe it can be generalised enough to stick up on the file exchange when it's done.
> >
> > Cheers,
> > Sven.
>
> --------------------------------------------------------------------------
> It might depend on how scattered they are. If it looks like a shotgun
> pattern, then it might be tough to pick any kind of order. If it's
> basically some kind of somwhat noisy path around a well defined
> perimeter of some shape, you might have a good algorithm. That's why
> it would be nice to see an example.
>
> John D'Errico posted a nice fitting routine here:
> http://www.mathworks.com/matlabcentral/fileexchange/24443-slm-shape-language-modeling
> Not sure if it works on closed contours though.

Could use Djikstra's algorithm. Start at some point, maybe the center point. Then order the points in order of shortest distance to that central point.

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
sorted points Sven 10 Nov, 2009 23:24:05
sort coordinates Sven 10 Nov, 2009 23:24:05
2d Sven 10 Nov, 2009 23:24:05
xy Sven 10 Nov, 2009 23:24:05
organise points Sven 10 Nov, 2009 23:24:05
rssFeed for this Thread

Contact us at files@mathworks.com