问题
I have a sample of some kind that can create somewhat noisy output. The sample is the result of some image processing from a camera, which indicates the heading of a blob of a certain color. It is an angle from around -45° to +45°, or a NaN
, which means that the blob is not actually in view.
In order to combat the noisy data, I felt that exponential smoothing would do the trick. However, I'm not sure how to handle the NaN
values.
On the one hand, involving them in the math would result in a NaN
average, which would then prevent any meaningful results. On the other hand, ignoring NaN
values completely would mean that a "no-detection" scenario would never be reported. And just to complicate things, the data is also noisy in that it can get false NaN
value, which ideally would be smoothed somehow to prevent random noise.
Any ideas about how I could implement such an exponential smoother?
回答1:
How about keeping two distributions? The first one can be your smoothed blob heading as usual, except if you get a NaN you instead just enter whatever the last seen non-NaN value was (or some other default); the other is a "NaN-distribution", which simply gets a 0 for every non-NaN value and 1 for every NaN (or something like that).
This way, even if it gets obscured, your primary distribution will keep predicting based on "last known heading", without getting garbage data or messing up the smoothing, but you'll also get a simultaneous spike on the NaN-distribution letting you know that something's up.
回答2:
Well, it really depends on what you are doing with the smoothed data. One thing you might try is to have an exponentially weighted smoothing of the blob velocity in addition to its location, where NaNs contribute a value of zero. When you encounter a NaN, you can then replace it with the projected position based on the previous position and the smoothed velocity. By smoothing the velocity you can prevent a whole sequence of NaNs from producing a completely crazily large or small value. This can result in values being out of [-45,45], which should capture that it is out of view and the side to which it left the view. Now, you will have to actually verify that this gives good results in your computer vision algorithm. If not, you might also want to try replacing NaNs with the previous value, or with zero, or to simply ignore the NaNs and see what works best.
来源:https://stackoverflow.com/questions/2791737/using-exponential-smoothing-with-nan-values