# Is there a clever way to implement cascaded moving average filters?

I'd like to effeciently approximate a gaussian filter's step response using cascaded moving average filters.

I know about recursive moving average, but is there some clever algorithm to cascade them apart from just putting them in series? CIC filters seem related but are mostly used for decimation, I'm interested in pulse shaping.

• This might be helpful. – Matt L. Dec 20 '18 at 15:44
• Thank you very much Matt! That's kind of what I had in mind. But I'm still wondering if there's an interesting non-obvious way of cascading them... I'm working in C/C++. – Albin Stigo Dec 20 '18 at 19:57

[EDIT:20181225, added a couple of references] This topic is coming back. P. Getreuer provides C code, and lists an handful of them in A survey of Gaussian convolution algorithms, Image Processing On Line, 2013:

Gaussian convolution is a common operation and building block for algorithms in signal and image processing. Consequently, its efficient computation is important, and many fast approximations have been proposed. In this survey, we discuss approximate Gaussian convolution based on finite impulse response filters, DFT and DCT based convolution, box filters, and several recursive filters. Since boundary handling is sometimes overlooked in the original works, we pay particular attention to develop it here. We perform numerical experiments to compare the speed and quality of the algorithms.

Here are a couple references:

This paper introduces a method for multidimensional Gaussian filtering using an efficient one-pass cascade of overlapping local average windows driven by prefix sums. Each local-average filter is implemented in n dimensions, with non-integer lengths, allowing accurate approximation of Gaussians of any variance. In axis oriented form the method has a scan-rate hardware realization and fast software implementation using minimal extra memory. In this latter case the new method consistently outperforms the fastest alternative Gaussian filtering method both in accuracy and speed.

Box filters have been used to speed up many computation-intensive operations in Image Processing and Computer Vision. They have the advantage of being fast to compute, but their adoption has been hampered by the fact that they present serious restrictions to filter construction. This paper relaxes these restrictions by presenting a method for automatically approximating an arbitrary 2-D filter by a box filter. To develop our method, we first formulate the approximation as a minimization problem and show that it is possible to find a closed form solution to a subset of the parameters of the box filter. To solve for the remaining parameters of the approximation, we develop two algorithms: Exhaustive Search for small filters and Directed Search for large filters. Experimental results show the validity of the proposed method.

This paper presents a simple and efficient method to convolve an image with a Gaussian kernel. The computation is performed in a constant number of operations per pixel using running sums along the image rows and columns. We investigate the error function used for kernel approximation and its relation to the properties of the input signal. Based on natural image statistics we propose a quadratic form kernel error function so that the output image l2 error is minimized. We apply the proposed approach to approximate the Gaussian kernel by linear combination of constant functions. This results in very efficient Gaussian filtering method. Our experiments show that the proposed technique is faster than state of the art methods while preserving a similar accuracy.

Image averaging can be performed very efficiently using either separable moving average filters or by using summed area tables, also known as integral images. Both these methods allow averaging to be performed at a small fixed cost per pixel, independent of the averaging filter size. Repeated filtering with averaging filters can be used to approximate Gaussian filtering. Thus a good approximation to Gaussian filtering can be achieved at a fixed cost per pixel independent of filter size. This paper describes how to determine the averaging filters that one needs to approximate a Gaussian with a specified standard deviation. The design of bandpass filters from the difference of Gaussians is also analysed. It is shown that difference of Gaussian bandpass filters share some of the attributes of log-Gabor filters in that they have a relatively symmetric transfer function when viewed on a logarithmic frequency scale and can be constructed with large bandwidths.

Gaussian filtering is an important tool in image processing and computer vision. In this paper we discuss the background of Gaussian filtering and look at some methods for implementing it. Consideration of the central limit theorem suggests using a cascade of simple'' filters as a means of computing Gaussian filters. Amongsimple'' filters, uniform-coefficient finite-impulse-response digital filters are especially economical to implement. The idea of cascaded uniform filters has been around for a while [13], [16]. We show that this method is economical to implement, has good filtering characteristics, and is appropriate for hardware implementation. We point out an equivalence to one of Burt's methods 1, 3 under certain circumstances. As an extension, we describe an approach to implementing a Gaussian Pyramid which requires approximately two addition operations per pixel, per level, per dimension. We examine tradeoffs in choosing an algorithm for Gaussian filtering, and finally discuss an implementation.