COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### how to fit a curve with piecewise line segments

• Follow

```I have a pretty noisy Nx2 data, where N is time stamp and the two columns are x, y position in a 2D plane.  The curve could look like this (upper-left panel)
http://www.pnas.org/content/103/18/7192/F1.large.jpg
or, here is a much less noisy example
http://live.ece.utexas.edu/research/doves/DovesImages/sub1.jpg

I wonder what's the algorithm that will find several line segments that best fit this kind of crazy curve, and is there a matlab code available to do it?  thanks
```
 0
Reply Po 1/22/2011 2:17:05 AM

```On Jan 21, 9:17=A0pm, "Po-He" <pohe...@gmail.com> wrote:
> I have a pretty noisy Nx2 data, where N is time stamp and the two columns=
are x, y position in a 2D plane. =A0The curve could look like this (upper-=
left panel)http://www.pnas.org/content/103/18/7192/F1.large.jpg
> or, here is a much less noisy examplehttp://live.ece.utexas.edu/research/=
doves/DovesImages/sub1.jpg
>
> I wonder what's the algorithm that will find several line segments that b=
est fit this kind of crazy curve, and is there a matlab code available to d=
o it? =A0thanks

---------------------------------------------------------------------------=
------
Looks like you already have a curve - the blue line.  Do you want to
fit a simpler, less wiggly curve?  Let's say that you could do that.
Then what?  What are you *really* after such that you think you need a
fitted curve?  What will a fitted curve do for you, assuming you had
one?  In other words, what's the larger picture - the context - here?
Can you share that, in case there's a way to get that without doing
some kind of curve fitting?
```
 0
Reply ImageAnalyst 1/22/2011 5:13:05 AM

```You might be interested in Douglas-Peucker line simplification algorithm. It is *not* a fit algorithm, just a method of selecting a subset of vertexes in the original curve such that the piecewise linear curve is well approximate the original data.

There are few such implementations on FEX.

Bruno
```
 0
Reply Bruno 1/22/2011 8:26:04 AM

```Thanks for the reply.  In the end, I'd like to know "when" and "how much" the line change its direction.  Therefore, a curvy turn is hard to decide the exact angle and the timing.  therefore, I'd like to fit these curves with a few straight line.  therefore, it's easier to calculate the angular change and the timming of direction change.  thank you

pohe

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <6e9e527d-d472-4d34-8646-98c94b51170d@c39g2000yqi.googlegroups.com>...
> On Jan 21, 9:17 pm, "Po-He" <pohe...@gmail.com> wrote:
> > I have a pretty noisy Nx2 data, where N is time stamp and the two columns are x, y position in a 2D plane.  The curve could look like this (upper-left panel)http://www.pnas.org/content/103/18/7192/F1.large.jpg
> > or, here is a much less noisy examplehttp://live.ece.utexas.edu/research/doves/DovesImages/sub1.jpg
> >
> > I wonder what's the algorithm that will find several line segments that best fit this kind of crazy curve, and is there a matlab code available to do it?  thanks
>
> ---------------------------------------------------------------------------------
> Looks like you already have a curve - the blue line.  Do you want to
> fit a simpler, less wiggly curve?  Let's say that you could do that.
> Then what?  What are you *really* after such that you think you need a
> fitted curve?  What will a fitted curve do for you, assuming you had
> one?  In other words, what's the larger picture - the context - here?
> Can you share that, in case there's a way to get that without doing
> some kind of curve fitting?
```
 0
Reply Po 1/22/2011 9:23:03 PM

```cool, that's exactly the thing I was looking for.  thanks for the help!!

pohe

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ihe4as\$sjq\$1@fred.mathworks.com>...
> You might be interested in Douglas-Peucker line simplification algorithm. It is *not* a fit algorithm, just a method of selecting a subset of vertexes in the original curve such that the piecewise linear curve is well approximate the original data.
>
> There are few such implementations on FEX.
>
> Bruno
```
 0
Reply Po 1/22/2011 9:37:03 PM

```On Jan 22, 4:23=A0pm, "Po-He" <pohe...@gmail.com> wrote:
> Thanks for the reply. =A0In the end, I'd like to know "when" and "how muc=
h" the line change its direction. =A0Therefore, a curvy turn is hard to dec=
ide the exact angle and the timing. =A0therefore, I'd like to fit these cur=
ves with a few straight line. =A0therefore, it's easier to calculate the an=
gular change and the timming of direction change. =A0thank you
>
> pohe
-------------------------------------------------------------------------
pohe:
Maybe you should look at the fractal dimension of the curve.  That
should be a good metric for characterizing how tortuous the curve is
and how completely it fills the plane.
ImageAnalyst

```
 0
Reply ImageAnalyst 1/22/2011 9:38:10 PM

```Thanks for the suggestion.  I'll look into that.

pohe

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5cf5be2b-27d4-450a-946a-9f6121f59953@k42g2000yqa.googlegroups.com>...
> On Jan 22, 4:23 pm, "Po-He" <pohe...@gmail.com> wrote:
> > Thanks for the reply.  In the end, I'd like to know "when" and "how much" the line change its direction.  Therefore, a curvy turn is hard to decide the exact angle and the timing.  therefore, I'd like to fit these curves with a few straight line.  therefore, it's easier to calculate the angular change and the timming of direction change.  thank you
> >
> > pohe
> -------------------------------------------------------------------------
> pohe:
> Maybe you should look at the fractal dimension of the curve.  That
> should be a good metric for characterizing how tortuous the curve is
> and how completely it fills the plane.
> ImageAnalyst
```
 0
Reply Po 1/25/2011 5:21:03 AM

6 Replies
742 Views

(page loaded in 0.157 seconds)

Similiar Articles:

7/26/2012 3:12:06 AM

 Reply: