<p>我有一个瓶颈在一个2D中值滤波器(3x3窗口)我使用了一个非常大的图像集,我想尝试和优化它。我测试了<code>scipy.ndimage</code>中值滤波器,以及<code>PIL</code>,<code>scipy.signal</code>和{<cd4>}。然而,在浏览中我了解到在C中有一个快速的O(n)中值过滤器(在恒定时间内的中值过滤请参见<a href="https://stackoverflow.com/questions/1309263/rolling-median-algorithm-in-c">Rolling median algorithm in C</a>),我想知道是否可以使用scipy.weave.inline?
有没有其他路线的建议?在</p>
<p>如果你还感兴趣,我可以试试纽比的整形和中位数:</p>
<pre><code>a= some big array
a.reshape(N,3,3) #N being specific to your array
[numpy.median(m) for m in a]
</code></pre>
<p>我不知道与你的testet方法相比,这是如何伸缩的,但是如果你想用C来优化,你可以在列表理解中固定for循环。。。在</p>