There are 7 messages in this thread.
You are currently looking at messages 0 to 7.
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______________________________
"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______________________________
"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______________________________
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______________________________
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 > > > >______________________________
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______________________________
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! =-----______________________________