Median Filtering in Constant Time

The median filter is one of the basic building blocks in many image processing situations. However, its use has long been hampered by its algorithmic complexity of O(r) in the kernel radius. With the trend toward larger images and proportionally larger filter kernels, the need for a more efficient median filtering algorithm becomes pressing. In this correspondence, a new, simple yet much faster algorithm exhibiting O(1) runtime complexity is described and analyzed. It is compared and benchmarked against previous algorithms. Extensions to higher-dimensional or higher-precision data and an approximation to a circular kernel are presented as well.

Published in the September 2007 issue of IEEE Transactions on Image Processing.

PDF (© IEEE, 2007)

The C source code is here: ctmf.c/ctmf.h. It is licensed under the GPL.

Comments: Simon Perreault <>