FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-20-2004, 03:50 AM
lucy
Guest
 
Posts: n/a
Default how to smooth a very toothshaped curve and make every part of the curve smooth and round?

Hi all,

I have a curve data which is very zigzag and toothshaped and not very
smooth.

The curve data is obtained when a user is dragging mouse over the figure
window...

So basically this is the trace of the mouse movement...

But due to hand-shaky and mouse mechanical problem this curve is not smooth
at all...

This curve data is now in two vectors:

How can I smooth this curve?

Thanks a lot.

(Please see the attached image to see the screenshot of the image... I am
also wondering how does those curve smooth in Photoshop and Microsoft make
out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will do
some averaging... but how to make those arcs smooth yet round?)

X=

54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134 138
142 146 150 154 158 162 166 170 174 178 182 186 190 194

Y=

0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577






Reply With Quote
  #2 (permalink)  
Old 08-20-2004, 05:20 AM
Fred Marshall
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round?


"lucy" <[email protected]> wrote in message
news:cg3ldl$83a$[email protected]..
> Hi all,
>
> I have a curve data which is very zigzag and toothshaped and not very
> smooth.
>
> The curve data is obtained when a user is dragging mouse over the figure
> window...
>
> So basically this is the trace of the mouse movement...
>
> But due to hand-shaky and mouse mechanical problem this curve is not

smooth
> at all...
>
> This curve data is now in two vectors:
>
> How can I smooth this curve?
>
> Thanks a lot.
>
> (Please see the attached image to see the screenshot of the image... I am
> also wondering how does those curve smooth in Photoshop and Microsoft make
> out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will do
> some averaging... but how to make those arcs smooth yet round?)
>
> X=
>
> 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134

138
> 142 146 150 154 158 162 166 170 174 178 182 186 190 194
>
> Y=
>
> 0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
> 0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
> 0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
> 0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577


You have some decisions to make up front:
1) are the end points to be considered "perfect" or to be treated as all the
other data points?
2) do you want first order / straight line? or do you want second order /
curve? or do you want something with inflection points?

Assuming you want a second order curve, you might fit the data in a least
squares sense to a second-order polynomial:
ax^2 + bx + c

This is easy to do with Excel - just compute the error squared at each point
and use the Tools / Solver to minimize the sum of all errors.

If you want the ends to nearly match the data, then weight the error heavily
at the ends by multiplying the error at the ends only by 10 or 50 or......

If you want the ends to exactly match the data, then weight the error very
heavily at the ends - this effectively removes two of the three degrees of
freedom that you have - so you will be only changing the curve.

Fred




Reply With Quote
  #3 (permalink)  
Old 08-20-2004, 07:09 AM
Peter Nachtwey
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round?

"lucy" <[email protected]> wrote in message
news:cg3ldl$83a$[email protected]..
> Hi all,
>
> I have a curve data which is very zigzag and toothshaped and not very
> smooth.
>
> The curve data is obtained when a user is dragging mouse over the figure
> window...
>
> So basically this is the trace of the mouse movement...
>
> But due to hand-shaky and mouse mechanical problem this curve is not

smooth
> at all...
>
> This curve data is now in two vectors:
>
> How can I smooth this curve?
>
> Thanks a lot.
>
> (Please see the attached image to see the screenshot of the image... I am
> also wondering how does those curve smooth in Photoshop and Microsoft make
> out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will do
> some averaging... but how to make those arcs smooth yet round?)
>
> X=
>
> 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134

138
> 142 146 150 154 158 162 166 170 174 178 182 186 190 194
>
> Y=
>
> 0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
> 0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
> 0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
> 0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577
>

There is an algorithm in "Numerical Recipes in C" whose name is
Savitzky-Golay. The routine name is savgol.c or savgol.cpp. Google for
savgol and you will get many hits. The savgol routine is a smoothing
routine where you have a lot of flexibilty over the order and width of the
smoothing.

Peter Nachtwey


Reply With Quote
  #4 (permalink)  
Old 08-20-2004, 04:14 PM
Andor Bariska
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part ofthe curve smooth and round?

lucy wrote:
....
> This curve data is now in two vectors:
>
> How can I smooth this curve?


If you don't have any statistics software available you can download the
free software package "R" from http://www.r-project.org. It contains
quite a few non-parametric regression functions, which are more or less
difficult to operate. For starters, try

help(loess)
help(dpill)
help(lockerns)
help(ksmooth)

at the command prompt.

Alternatively, I'm sure Matlab has similar functions. Perhaps Excel has
too? I don't know.

Regards,
Andor

Reply With Quote
  #5 (permalink)  
Old 08-20-2004, 06:24 PM
Fred Marshall
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round?

Either I made a mistake or there's a good reason that I've not thought
through ... but normalizing the X axis to start at zero seemed to give
different / better results. I don't think that should be - but that's what
happened.

Fred

"Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message
news:[email protected]..
>
> "lucy" <[email protected]> wrote in message
> news:cg3ldl$83a$[email protected]..
> > Hi all,
> >
> > I have a curve data which is very zigzag and toothshaped and not very
> > smooth.
> >
> > The curve data is obtained when a user is dragging mouse over the figure
> > window...
> >
> > So basically this is the trace of the mouse movement...
> >
> > But due to hand-shaky and mouse mechanical problem this curve is not

> smooth
> > at all...
> >
> > This curve data is now in two vectors:
> >
> > How can I smooth this curve?
> >
> > Thanks a lot.
> >
> > (Please see the attached image to see the screenshot of the image... I

am
> > also wondering how does those curve smooth in Photoshop and Microsoft

make
> > out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will

do
> > some averaging... but how to make those arcs smooth yet round?)
> >
> > X=
> >
> > 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134

> 138
> > 142 146 150 154 158 162 166 170 174 178 182 186 190 194
> >
> > Y=
> >
> > 0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
> > 0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
> > 0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
> > 0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577

>
> You have some decisions to make up front:
> 1) are the end points to be considered "perfect" or to be treated as all

the
> other data points?
> 2) do you want first order / straight line? or do you want second order /
> curve? or do you want something with inflection points?
>
> Assuming you want a second order curve, you might fit the data in a least
> squares sense to a second-order polynomial:
> ax^2 + bx + c
>
> This is easy to do with Excel - just compute the error squared at each

point
> and use the Tools / Solver to minimize the sum of all errors.
>
> If you want the ends to nearly match the data, then weight the error

heavily
> at the ends by multiplying the error at the ends only by 10 or 50 or......
>
> If you want the ends to exactly match the data, then weight the error very
> heavily at the ends - this effectively removes two of the three degrees of
> freedom that you have - so you will be only changing the curve.
>
> Fred
>
>
>
>



Reply With Quote
  #6 (permalink)  
Old 08-20-2004, 08:13 PM
axlq
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round?

In article <[email protected]>,
Peter Nachtwey <[email protected]> wrote:
>There is an algorithm in "Numerical Recipes in C" whose name is
>Savitzky-Golay. The routine name is savgol.c or savgol.cpp.
>Google for savgol and you will get many hits. The savgol routine
>is a smoothing routine where you have a lot of flexibilty over the
>order and width of the smoothing.


The Numerical Recipes chapter (and code) is here:
http://www.library.cornell.edu/nr/bookcpdf/c14-8.pdf

-Alex
Reply With Quote
  #7 (permalink)  
Old 08-20-2004, 10:25 PM
jim
Guest
 
Posts: n/a
Default Re: how to smooth a very toothshaped curve and make every part of thecurve smooth and round?



lucy wrote:
>


>
> But due to hand-shaky and mouse mechanical problem this curve is not smooth
> at all...
>
> This curve data is now in two vectors:
>
> How can I smooth this curve?
>
> Thanks a lot.
>
> (Please see the attached image to see the screenshot of the image... I am
> also wondering how does those curve smooth in Photoshop and Microsoft make
> out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will do
> some averaging... but how to make those arcs smooth yet round?)
>
> X=
>
> 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134 138
> 142 146 150 154 158 162 166 170 174 178 182 186 190 194
>
> Y=
>
> 0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
> 0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
> 0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
> 0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577


You say this data is about mouse movement measured in what? Screen
pixels? So you have a range in X of about 140 and a range in y of about
0.3. When plotted to a screen won't that look like a straight horizontal
line? You can't get any smoother than that.

-jim


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find the pass transistor's working curve under 1.2V? Weng Tianxiang FPGA 11 05-09-2007 08:23 PM
Help on finding the best lin/curve fit Parthasarathy DSP 2 07-09-2004 06:33 AM
How to implement a filter with arbitrary amplitude curve and phase curve? jason han DSP 5 11-20-2003 07:07 PM
SOS!any good curve fitting/data analysis technique for this problem? walala DSP 20 10-25-2003 07:56 AM


All times are GMT +1. The time now is 03:41 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved