Sign in

username:

password:



Not a member?

Search compdsp



Search tips

comp.dsp by Keywords

Adaptive Filter | ADPCM | ADSP | ADSP-2181 | Aliasing | AMR | Anti-Aliasing | ARMA | Autocorrelation | AutoCovariance | Beamforming | Bessel | Blackfin | Butterworth | C6713 | CCS | Chebyshev | CIC Filter | Circular Convolution | Code Composer Studio | Comb Filter | Compression | Convolution | Cross Correlation | DCT | Decimation | Deconvolution | Demodulation | DM642 | DSP Boards | DSP/BIOS | DTMF | Echo Cancellation | Equalization | Equalizer | ETSI | EZLITE (Ez-kit Lite) | FFT | FFTW | FIR Filter | Fixed Point | FSK | G.711 | G.723 | G.729 | Gaussian Noise | Goertzel | GPIO | Hilbert Transform | IFFT | IIR Filter | Interpolation | Invariance | JTAG | Kalman | Laplace Transform | Levinson | LPC | McBSP | MIPS | Modulation | MPEG | Multirate | Notch Filter | Nyquist | OFDM | Oversampling | Pink Noise | Pitch | PLL | Polyphase | QAM | QDMA | Quantization | Quantizer | Radar | Random Noise | Reed Solomon | Remez | Resampling | RTDX | Sampling | Sharc | TI C6711 | Undersampling | Viterbi | Wavelets | White Noise | Wiener Filter | Windowing | XDS510PP | Z Transform

Sponsor

Industry's highest performing at the lowest power DSPs now as low as $5.00*
Start development today!
*volume pricing for 10ku

Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | Comp.DSP | how to smooth a very toothshaped curve and make every part of the curve smooth and round?

There are 7 messages in this thread.

You are currently looking at messages 0 to 7.


how to smooth a very toothshaped curve and make every part of the curve smooth and round? - lucy - 2004-08-19 21:50:00

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






______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - Fred Marshall - 2004-08-19 23:20:00



"lucy" <l...@yahoo.com> wrote in message
news:cg3ldl$83a$1...@news.Stanford.EDU...
> 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




______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - Peter Nachtwey - 2004-08-20 01:09:00

"lucy" <l...@yahoo.com> wrote in message
news:cg3ldl$83a$1...@news.Stanford.EDU...
> 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


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - Andor Bariska - 2004-08-20 10:14:00

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

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - Fred Marshall - 2004-08-20 12:24:00

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:s...@centurytel.net...
>
> "lucy" <l...@yahoo.com> wrote in message
> news:cg3ldl$83a$1...@news.Stanford.EDU...
> > 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
>
>
>
>


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - axlq - 2004-08-20 14:13:00

In article <_f...@comcast.com>,
Peter Nachtwey <p...@deltacompsys.com> 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
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: how to smooth a very toothshaped curve and make every part of the curve smooth and round? - jim - 2004-08-20 16:25:00


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! =-----
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.