中值滤波超高效的实现 [英] Median Filter Super efficient implementation

查看:211
本文介绍了中值滤波超高效的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个ANSI C实现快速/高效的中值滤波。任何指针?

I am looking for a Ansi C implementation of a fast/efficient median filter. Any pointers?

到目前为止,我已经找到了以下实现,这是好的,但我很好奇,就越快。我只需要1维度。

So far, I have found the following implementation, which is good but I am curious on faster ones. I only need for 1 dimension.

推荐答案

我需要从非常嘈杂的CPU消耗数据提取的信号。这里的杰夫·麦克林托克中值滤波...

I needed to extract a signal from very noisy CPU consumption data. Here's the Jeff McClintock median filter...

初​​始化平均和中值为零,然后为每个样品英寸朝向由一个小增量的输入样本的中位数。它最终将稳定在一个点,约50%的输入样本的更大,并且50%的小于中值。  增量的大小应正比于实际的位数。因为我们不知道实际的中位数,我用的是平均值作为一个粗略的估计。步长计算为0.01倍的估计。较小的步长大小是更准确,但需要更长的时间来解决。

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 );
}

这篇关于中值滤波超高效的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆