Median Filter Super efficient implementation

喜欢而已 提交于 2019-12-03 10:09:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!