# Dots wobble, but they don't fall down.

August 4, 2010 2:05 PM Subscribe

How would you quantify wobble?

I'm measuring the position of a dot in a video using OpenCV.

I get an X and Y coordinate 10 times a second, over about 5-10 seconds, for a total of about 50-100 coordinate pairs.

I want to somehow quantify how much the dot "wobbles". I tried a few things - like for example, measuring at each point the distance from the overall average centerpoint, and taking the sum squared differences from that point normalized by number of observations - but nothing I've tried seems to correlate very well (or at all) with my visual estimation of the wobble.

Any ideas?

I'm measuring the position of a dot in a video using OpenCV.

I get an X and Y coordinate 10 times a second, over about 5-10 seconds, for a total of about 50-100 coordinate pairs.

I want to somehow quantify how much the dot "wobbles". I tried a few things - like for example, measuring at each point the distance from the overall average centerpoint, and taking the sum squared differences from that point normalized by number of observations - but nothing I've tried seems to correlate very well (or at all) with my visual estimation of the wobble.

Any ideas?

Wobble is a funny word and I haven't thought about it much, but ...

0-dimensional wobble: Something is supposed to be at a point and stay there, dammit. A vase in an earthquake wobbles away from its fixed point.

linear wobble: Something is supposed to move in a path. I expect it to be in that straight path. A skier on a defined path briefly loses balance, then rights herself.

rotational wobble: Something is supposed to spin. It's spin is not smooth. A poorly-balanced tire at high angular velocity.

The other way of thinking about wobble is flying off the cliff wobble (type A), stable wobble (type B), and recovery wobble (type C). The skier falls over. The unbalanced tire just wobbles but it doesn't do anything but probably screw up my alignment. The oscillations of the vase about its fixed point decrease until it is resting back where it ought to be, pre-tremor.

So the measurement of wobble depends on what kinds of wobble you are expecting in your point.

Imagine a 0-dimensional, type C wobble. Let's say you've got your camera pointed right down at the head of a Weeble-Wobble. I wobble my Weeble-Wobble, and while it does not fall down, if I drew a small time envelope around the coordinates of the Weeble-Wobble's fontanelle, I would expect a large deviation from the centerpoint at first, then decreasing as kinetic energy is lost to friction, noise, and so forth.

Perhaps you could factor in the direction of wobble from a fixed angle. Wobble to the left (178 degrees), to the right (5 degrees), to the left (184 degrees), to the right (-2 degrees). If your sample rate was high enough, you could start tracing paths ...

I know we all walk the wibbly-wobbly walk, but which of the wobbles are you wibbling?

posted by adipocere at 2:30 PM on August 4, 2010

0-dimensional wobble: Something is supposed to be at a point and stay there, dammit. A vase in an earthquake wobbles away from its fixed point.

linear wobble: Something is supposed to move in a path. I expect it to be in that straight path. A skier on a defined path briefly loses balance, then rights herself.

rotational wobble: Something is supposed to spin. It's spin is not smooth. A poorly-balanced tire at high angular velocity.

The other way of thinking about wobble is flying off the cliff wobble (type A), stable wobble (type B), and recovery wobble (type C). The skier falls over. The unbalanced tire just wobbles but it doesn't do anything but probably screw up my alignment. The oscillations of the vase about its fixed point decrease until it is resting back where it ought to be, pre-tremor.

So the measurement of wobble depends on what kinds of wobble you are expecting in your point.

Imagine a 0-dimensional, type C wobble. Let's say you've got your camera pointed right down at the head of a Weeble-Wobble. I wobble my Weeble-Wobble, and while it does not fall down, if I drew a small time envelope around the coordinates of the Weeble-Wobble's fontanelle, I would expect a large deviation from the centerpoint at first, then decreasing as kinetic energy is lost to friction, noise, and so forth.

Perhaps you could factor in the direction of wobble from a fixed angle. Wobble to the left (178 degrees), to the right (5 degrees), to the left (184 degrees), to the right (-2 degrees). If your sample rate was high enough, you could start tracing paths ...

I know we all walk the wibbly-wobbly walk, but which of the wobbles are you wibbling?

posted by adipocere at 2:30 PM on August 4, 2010

This is similar to measuring noise in an analog signal, which is usually calculated as RMS (root mean square) of absolute values. How you measure absolute value of the 'error' signal in 2D space is another matter.

posted by rocket88 at 2:35 PM on August 4, 2010

posted by rocket88 at 2:35 PM on August 4, 2010

why wouldn't "wobble" simply be the standard deviation of the frequency distribution of the distances that you are already calculating?

low wobble, should have a very tight distribution with a very low standard deviation.

high wobble should have a higher s.d.

so "wobble" could simply be proportionate to the s.d.

posted by DavidandConquer at 2:45 PM on August 4, 2010

low wobble, should have a very tight distribution with a very low standard deviation.

high wobble should have a higher s.d.

so "wobble" could simply be proportionate to the s.d.

posted by DavidandConquer at 2:45 PM on August 4, 2010

Find the extreme lowest and highest X and Y values to determine the boundaries of the wobble area. Divide that area into quadrants. Whenever the dot enters a different quadrant and remains there for a given period — say, five frames — increment its wobblecount by one. Divide the final wobblecount by the total number of frames in the set to find the amount of wobble for that dot.

This won't measure the magnitude of the wobbles but it will tell you how quickly they happen. I assume that's what you mean by wanting to quantify "how much" wobble you're dealing with.

posted by The Winsome Parker Lewis at 2:48 PM on August 4, 2010

This won't measure the magnitude of the wobbles but it will tell you how quickly they happen. I assume that's what you mean by wanting to quantify "how much" wobble you're dealing with.

posted by The Winsome Parker Lewis at 2:48 PM on August 4, 2010

*but nothing I've tried seems to correlate very well (or at all) with my visual estimation of the wobble.*

I thought Heisenberg said you can't do that.

You can choose either time (over x seconds, dot will wobble[stray from where its supposed to be] y times), or location.

(yes, yes...i know he was talking subatomic...but since you have so many data points...they seem to be doing the same type of thing).

OR...have you looked at the data from the perspective of "the longer you look at the phenomenon, the greater the wobble (x seconds=average location of dot is y distance away from where its supposed to be...)

It would also help to know where the wobble is going...

Are the wobbles going in every direction, or just one direction, or what?

I might be talking out of my ass...but is it consistently going in ONE direction...?

posted by hal_c_on at 2:56 PM on August 4, 2010

How about sum squared from the overrall average centerpoint weighted by the change in previous position of the point? As oblio_one said, the method you described would treat points equidistant from the center the same even if the point actually moved a little.

posted by Green With You at 3:25 PM on August 4, 2010

posted by Green With You at 3:25 PM on August 4, 2010

You could also multiply by the total variation (the sum of the absolute/squared differences between the point's positions at time k vs. time k-1)

posted by Earl the Polliwog at 4:55 PM on August 4, 2010

posted by Earl the Polliwog at 4:55 PM on August 4, 2010

It depends on what you mean exactly by wobble, but if we take the analogy of travelling in a car, consider what is "comfortable" (analogous to no wobble) vs. what is "uncomfortable" (analogous to wobble):

- Not moving (no velocity, thus 1st derivative of position = 0) is comfortable.

- Moving (no acceleration, thus 2nd derivative of position = 0) is still comfortable.

- Accelerating smoothly (accelerating at a constant rate, thus 3rd derivative of position = 0) is still comfortable.

The "uncomfortable" (wobble) comes when the acceleration is not constant -- that is, the rate of change of acceleration is not 0. This is called jerk. I would expect that the wobble is well characterized by x''' and y'''.

The problem with statistical-type methods (such as standard deviation, RSS) is that it doesn't take into consideration the behaviour of the point in time. For example, a point moving slowly back and forth on the x axis would have a high standard deviation, since there are many points that are "far" from the average position. Nonetheless, its behaviour would not be considered wobble.

posted by Simon Barclay at 5:44 PM on August 4, 2010

- Not moving (no velocity, thus 1st derivative of position = 0) is comfortable.

- Moving (no acceleration, thus 2nd derivative of position = 0) is still comfortable.

- Accelerating smoothly (accelerating at a constant rate, thus 3rd derivative of position = 0) is still comfortable.

The "uncomfortable" (wobble) comes when the acceleration is not constant -- that is, the rate of change of acceleration is not 0. This is called jerk. I would expect that the wobble is well characterized by x''' and y'''.

The problem with statistical-type methods (such as standard deviation, RSS) is that it doesn't take into consideration the behaviour of the point in time. For example, a point moving slowly back and forth on the x axis would have a high standard deviation, since there are many points that are "far" from the average position. Nonetheless, its behaviour would not be considered wobble.

posted by Simon Barclay at 5:44 PM on August 4, 2010

I'm wondering if what correlates to wobble isn't RMS position (versus some calculated center) but the RMS of some derivative of position, maybe acceleration. If you calculated RMS(accel), you wouldn't see movement along a straight line as wobble, but you'd more or less see the g-forces on your dot. Would that come close?

Another (semi-related) thought would be to view the position data in the frequency domain (keep a running FFT, maybe windowed so you just look at the last N datapoints) and characterize anything with high-frequency components as "wobbly."

posted by range at 7:15 PM on August 4, 2010

Another (semi-related) thought would be to view the position data in the frequency domain (keep a running FFT, maybe windowed so you just look at the last N datapoints) and characterize anything with high-frequency components as "wobbly."

posted by range at 7:15 PM on August 4, 2010

Sorry, it's late and I missed Simon Barclay's excellent comment. I think he may have it nailed with jerk (or maybe even the later derivatives; count me among those who vote for snap, crackle, and pop, respectively).

posted by range at 7:21 PM on August 4, 2010

posted by range at 7:21 PM on August 4, 2010

Maybe it would be helpful to look at the taxicab distance of each point, rather than the Euclidean distance. It was the first thing that popped into my mind when I read your question, at least. Dots that move more regardless of direction will have a greater taxicab distance than those that don't, and perhaps this would correlate with your visual perception of wobble?

posted by wondercow at 7:48 PM on August 4, 2010

posted by wondercow at 7:48 PM on August 4, 2010

Quick, untested, algorithm. What you basically have is x(t) and y(t) sampled at 5-10 hz. Now, an ideal circle is defined as x(t) = r*cos(2pi*f * t) and y(t) = r*sin(2*pi*t). I wonder if you can try to fit your data to some kind of model (like the one I gave for a dot that moves in a perfect circle) and look at how far it deviates along the model path.

posted by scalespace at 8:02 PM on August 4, 2010

posted by scalespace at 8:02 PM on August 4, 2010

I would look into thermal elipsoid plots from single crystal x-ray structural determination. When you refine the atom position anisotropically it generates a wobble in each of the three directions and you show the position as an ellipsis wherein the probability of the atom being present in that space is 50% (usually)

I dont have the equations off the top of my head, but it should put you in the right direction.

posted by koolkat at 1:48 AM on August 5, 2010

I dont have the equations off the top of my head, but it should put you in the right direction.

posted by koolkat at 1:48 AM on August 5, 2010

Frequency and amplitude are enough for linear wobble. Radial wobble would also have an angular frequency and amplitude (i.e. how often does the angle change and how big are the steps when it does).

posted by DU at 4:29 AM on August 5, 2010

posted by DU at 4:29 AM on August 5, 2010

This thread is closed to new comments.

Since you're getting discrete measurements at regular time intervals, can get speed by storing position at each measurement and calculating distance from last position as well as (or instead of) from center.

Actually, it sounds like your algorithm treats two positions which are equidistant from center (say either side of a long pendulum like movement) as the same position (same distance from center, just opposite directions.) could be just me interpreting you wrong, but might explain why no correlation if so.

posted by oblio_one at 2:14 PM on August 4, 2010