1 Efficient 3x3 Median Filter Computations Manfred Kopp Institute of Computer Graphics Technical University of Vienna Karlsplatz 13/186-2 A-1040 Wien, Austria m.kopp@ieee.org Werner Purgathofer Institute of Computer Graphics Technical University of Vienna Karlsplatz 13/186-2 A-1040 Wien, Austria purgathofer@cg.tuwien.ac.at Abstract This Paper presents an efficient algorithm for median filtering with a 3x3 filter kernel with only about 9 comparisons per pixel using spatial coherence between neighbouring filter computations. The basic algorithm calculates two medians in one step and reuses sorted slices of three vertical neighbouring pixels. An extension of this algorithm for 2D spatial coherence is also examined, which calculates four medians per step. Even though theoretical results would yield 5% performance increase compared to the basic algorithm, experimental results showed less significant increase or even worse performance dependent on the hardware. Keywords: image processing, filtering, 3x3 median kernel, spatial coherence 1 Introduction The median filter is often used to remove "shot" noise, pixel dropouts and other spurious features of single pixel extent while preserving overall image quality [Huang 1981] [Paeth 1986a] [Paeth 1986b]. In contrast, low pass filters would only blurr the noise instead of removing it. An efficient algorithm to determine the median is desired, because this operation often has to be repeated millions of times for filtering large images. One simple approach, which is often found in image processing textbooks, is to calculate the 3x3 median using a simple sorting algorithm, like bubble sort or quicksort, and pick the 5th element after the sorting. An improvement to this simple technique is only to sort until the 5th element is determined. For example a modified bubble sort can be used to sort until the 5th element. This approach yields 30 comparisons for one median calculation. A better approach is published in the first Volume of the Graphics Gems series by Paeth [Paeth 1990]. This approach is based on a successive minmax-elimination: the minimum and the maximum of the first six elements are determined and eliminated. Then the 7th element is added to the remaining four of the first pass and the minimum and the maximum of the five elements are determined and eliminated. This scheme is repeated until the 9th element is