问题
I am looking for a Ansi C implementation of a fast/efficient median filter. Any pointers?
So far, I have found the following implementation, which is good but I am curious on faster ones. I only need for 1 dimension.
回答1:
I needed to extract a signal from very noisy CPU consumption data. Here's the Jeff McClintock median filter...
Initialize the average and median to zero, then for each sample 'inch' the median toward the input sample by a small increment. Eventually it will settle at a point where about 50% of the input samples are greater, and 50% are less than the median. The size of the increment should be proportional to the actual median. Since we don't know the actual median, I use the average as an rough estimate. The step size is calculated as 0.01 times the estimate. Smaller step sizes are more accurate, but take longer to settle.
float median = 0.0f;
float average = 0.0f;
// for each sample
{
average += ( abs(sample) - average ) * 0.1f; // rough running average magnitude.
median += _copysign( average * 0.01, sample - median );
}
来源:https://stackoverflow.com/questions/11482529/median-filter-super-efficient-implementation