Running Max/Min Filters Using 1+o(1) Comparisons per Sample

A running max (or min) filter asks for the maximum or (minimum) elements within a fixed-length sliding window. The previous best deterministic algorithm (developed by Gil and Kimmel, and refined by Coltuc) can compute the 1D max filter using 1.5+o(1) comparisons per sample in the worst case. The best-known algorithm for independent and identically distributed input uses 1.25+o(1) expected comparisons per sample (by Gil and Kimmel). In this work, we show that the number of comparisons can be reduced to 1+o(1) comparisons per sample in the worst case. As a consequence of the new max/min filters, the opening (or closing) filter can also be computed using 1+o(1) comparisons per sample in the worst case, where the previous best work requires 1.5+o(1) comparisons per sample (by Gil and Kimmel); and computing the max and min filters simultaneously can be done in 2+o(1) comparisons per sample in the worst case, where the previous best work (by Lemire) requires three comparisons per sample. Our improvements over the previous work are asymptotic, that is, the number of comparisons is reduced only when the window size is large.

[1]  Ron Kimmel,et al.  Efficient Dilation, Erosion, Opening and Closing Algorithms , 2000, ISMM.

[2]  Xinhua Zhuang,et al.  Image Analysis Using Mathematical Morphology , 1987, IEEE Transactions on Pattern Analysis and Machine Intelligence.

[3]  Steven Skiena,et al.  Lowest common ancestors in trees and directed acyclic graphs , 2005, J. Algorithms.

[4]  Daniel Lemire,et al.  Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element , 2006, Nord. J. Comput..

[5]  Uzi Vishkin,et al.  On Finding Lowest Common Ancestors: Simplification and Parallelization , 1988, AWOC.

[6]  Marcel van Herk A fast algorithm for local minimum and maximum filters on rectangular and octagonal kernels , 1992, Pattern Recognit. Lett..

[7]  Ioannis Pitas,et al.  Fast algorithms for running ordering and max/min calculation , 1989 .

[8]  Jaakko T. Astola,et al.  Improving Gil-Werman Algorithm for Running Min and Max Filters , 1997, IEEE Trans. Pattern Anal. Mach. Intell..

[9]  Robert E. Tarjan,et al.  Scaling and related techniques for geometry problems , 1984, STOC '84.

[10]  Robert E. Tarjan,et al.  Fast Algorithms for Finding Nearest Common Ancestors , 1984, SIAM J. Comput..

[11]  Jean Vuillemin,et al.  A unifying look at data structures , 1980, CACM.

[12]  Stephen Alstrup,et al.  Nearest common ancestors: a survey and a new distributed algorithm , 2002, SPAA.

[13]  Michael Werman,et al.  Computing 2-D Min, Median, and Max Filters , 1993, IEEE Trans. Pattern Anal. Mach. Intell..

[14]  Mikhail J. Atallah,et al.  Data structures for range minimum queries in multidimensional arrays , 2010, SODA '10.

[15]  Dinu Coltuc Mathematical Complexity of Running Filters on Semi-Groups and Related Problems , 2008, IEEE Transactions on Signal Processing.

[16]  Pierre Soille,et al.  Morphological Image Analysis: Principles and Applications , 2003 .

[17]  Stephen Alstrup,et al.  Nearest Common Ancestors: A Survey and a New Algorithm for a Distributed Environment , 2004, Theory of Computing Systems.