Skip to main content
QUICK REVIEW

[论文解读] Median Filtering is Equivalent to Sorting

Jukka Suomela|arXiv (Cornell University)|Jun 6, 2014
Algorithms and Data Compression参考文献 15被引用 8
一句话总结

本文证明了中值滤波在计算上等价于分段排序:提出了一种新算法,通过先对大小为 $k$ 的块进行排序,再进行线性时间后处理,来计算滑动窗口中值。关键洞见是维护两个已排序的双向链表,以高效模拟通过时间反转删除和高德纳舞蹈链技术实现的窗口更新,其性能与基于堆的方法相当,且在部分有序数据上表现更优。

ABSTRACT

This work shows that the following problems are equivalent, both in theory and in practice: - median filtering: given an $n$-element vector, compute the sliding window median with window size $k$, - piecewise sorting: given an $n$-element vector, divide it in $n/k$ blocks of length $k$ and sort each block. By prior work, median filtering is known to be at least as hard as piecewise sorting: with a single median filter operation we can sort $Θ(n/k)$ blocks of length $Θ(k)$. The present work shows that median filtering is also as easy as piecewise sorting: we can do median filtering with one piecewise sorting operation and linear-time postprocessing. In particular, median filtering can directly benefit from the vast literature on sorting algorithms---for example, adaptive sorting algorithms imply adaptive median filtering algorithms. The reduction is very efficient in practice---for random inputs the performance of the new sorting-based algorithm is on a par with the fastest heap-based algorithms, and for benign data distributions it typically outperforms prior algorithms. The key technical idea is that we can represent the sliding window with a pair of sorted doubly-linked lists: we delete items from one list and add items to the other list. Deletions are easy; additions can be done efficiently if we reverse the time twice: First we construct the full list and delete the items in the reverse order. Then we undo each deletion with Knuth's dancing links technique.

研究动机与目标

  • 建立中值滤波与分段排序在理论和实践上的等价性。
  • 开发一种利用现有排序算法提升性能的新型中值滤波算法。
  • 证明基于排序的中值滤波可达到或超过传统基于堆方法的效率。
  • 展示该新算法可受益于自适应与缓存高效排序技术。
  • 在多种数据分布和硬件平台上验证该算法的性能。

提出的方法

  • 该算法将输入向量划分为 $n/k$ 个大小为 $k$ 的块,并使用任意比较排序算法对每个块进行排序。
  • 维护两个已排序的双向链表 $L_A$ 和 $L_B$ 来表示滑动窗口,其中 $L_A$ 保存当前窗口内容,$L_B$ 累积新元素。
  • 为高效插入新元素到 $L_B$,算法采用时间反转:先构建新元素的完整列表,再按逆序删除。
  • 通过标准双向链表操作执行删除,插入操作则通过使用高德纳舞蹈链技术撤销删除来模拟。
  • 通过双指针方式合并两个已排序列表,线性时间计算中值,同时维护指向中间元素的指针。
  • 在初始排序阶段后,后处理以 $O(n)$ 时间计算输出向量,整体时间复杂度为 $O(n\log k)$。

实验结果

研究问题

  • RQ1中值滤波在理论上和实践中是否与分段排序在计算上等价?
  • RQ2基于排序的方法能否实现与基于堆的中值滤波算法相当或更优的性能?
  • RQ3与随机输入相比,该算法在部分有序或结构化数据上的表现如何?
  • RQ4现有的自适应与缓存优化排序算法能否被直接用于提升中值滤波性能?
  • RQ5数据局部性和内存访问模式对中值滤波算法效率有何影响?

主要发现

  • 所提出的基于排序的中值滤波算法在最坏情况时间复杂度上与基于堆的方法保持一致,为 $O(n\log k)$,但实际性能通常更优。
  • 对于随机输入,该新算法与最快的基于堆实现性能相当。
  • 在部分有序或结构化输入上,基于排序的算法显著优于基于堆的方法,尤其得益于更好的缓存效率。
  • 该算法利用自适应排序(如 TimSort 或其他自适应算法),在真实世界数据分布上表现出更优性能。
  • 在 4,620 次基准测试中,SortMedian 始终优于 HeapMedian,尤其在窗口尺寸较大时表现更佳。
  • 使用时间反转删除与舞蹈链技术,实现了对已排序列表的高效插入,使算法既简洁又高性能。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。