A Survey of Gaussian Convolution Algorithms
Data Structures | Typedefs | Functions
Extended box filter Gaussian convolution

An improvement of box filtering with continuous selection of sigma. More...

Detailed Description

An improvement of box filtering with continuous selection of sigma.

This code implements the extended box filter approximation of Gaussian convolution proposed by Gwosdek, Grewenig, Bruhn, and Weickert. The extended box filter is the recursive filter

\[ u_n = u_{n-1}+c_1(f_{n+r+1}-f_{n-r-2})+c_2(f_{n+r}-f_{n-r-1}). \]

The process to use these functions is the following:

  1. ebox_precomp() to precompute coefficients for the convolution
  2. ebox_gaussian_conv() or ebox_gaussian_conv_image() to perform the convolution itself (may be called multiple times if desired)
Example
buffer = (num *)malloc(sizeof(num) * N);
free(buffer);
Reference
  • P. Gwosdek, S. Grewenig, A. Bruhn, J. Weickert, "Theoretical Foundations of Gaussian Convolution by Extended Box Filtering," International Conference on Scale Space and Variational Methods in Computer Vision, pp. 447-458, 2011. http://dx.doi.org/10.1007/978-3-642-24785-9_38

Data Structures

struct  ebox_coeffs_
 Coefficients for extended box filter Gaussian approximation. More...
 

Typedefs

typedef struct ebox_coeffs_ ebox_coeffs
 Coefficients for extended box filter Gaussian approximation.
 

Functions

static void ebox_filter (num *dest, long dest_stride, const num *src, long src_stride, long N, long r, num c_1, num c_2)
 Perform one pass of extended box filtering. More...
 
void ebox_precomp (ebox_coeffs *c, double sigma, int K)
 Precompute coefficients for extended box filtering. More...
 
void ebox_gaussian_conv (ebox_coeffs c, num *dest, num *buffer, const num *src, long N, long stride)
 Extended box filtering approximation of Gaussian convolution. More...
 
void ebox_gaussian_conv_image (ebox_coeffs c, num *dest, num *buffer, const num *src, int width, int height, int num_channels)
 Extended box filtering approximation of 2D Gaussian convolution. More...
 

Function Documentation

static void ebox_filter ( num dest,
long  dest_stride,
const num src,
long  src_stride,
long  N,
long  r,
num  c_1,
num  c_2 
)
static

Perform one pass of extended box filtering.

Parameters
destdestination array
dest_stridestride between successive samples of dest
src_stridesrc array (must be distinct from dest)
src_stridestride between successive samples of src
Nnumber of samples
rradius of the inner box
c_1weight of the outer box
c_2weight of the inner box

This routine performs one pass of extended box filtering with inner box radius r,

\[ u_n = u_{n-1}+c_1(f_{n+r+1}-f_{n-r-2})+c_2(f_{n+r}-f_{n-r-1}). \]

Note
The computation is out-of-place, src and dest must be distinct.

Definition at line 69 of file gaussian_conv_ebox.c.

void ebox_gaussian_conv ( ebox_coeffs  c,
num dest_data,
num buffer_data,
const num src,
long  N,
long  stride 
)

Extended box filtering approximation of Gaussian convolution.

Parameters
cebox_coeffs created by ebox_precomp()
dest_datadestination array
buffer_dataarray with space for at least N samples
srcinput, overwritten if src = dest_data
Nnumber of samples
stridestride between successive samples

This routine performs the extended box filtering approximation of Gaussian convolution by multiple passes of the extended box filter. The filtering itself is performed by ebox_filter().

Since ebox_filter() requires that the source and destination are distinct, the iteration alternates the roles of two arrays. See box_gaussian_conv() for more detailed discussion.

The convolution can be performed in-place by setting src = dest_data (the source array is overwritten with the result). However, buffer_data must be distinct from dest_data.

Definition at line 117 of file gaussian_conv_ebox.c.

void ebox_gaussian_conv_image ( ebox_coeffs  c,
num dest,
num buffer,
const num src,
int  width,
int  height,
int  num_channels 
)

Extended box filtering approximation of 2D Gaussian convolution.

Parameters
cebox_coeffs created by ebox_precomp()
destdestination image
bufferarray with at least max(width,height) samples
srcinput image, overwritten if src = dest
widthimage width
heightimage height
num_channelsnumber of image channels

Similar to ebox_gaussian_conv(), this routine approximates 2D Gaussian convolution with extended box filtering.

The convolution can be performed in-place by setting src = dest (the source array is overwritten with the result). However, buffer must be be distinct from dest.

Definition at line 185 of file gaussian_conv_ebox.c.

void ebox_precomp ( ebox_coeffs c,
double  sigma,
int  K 
)

Precompute coefficients for extended box filtering.

Parameters
cebox_coeffs pointer to hold precomputed coefficients
sigmaGaussian standard deviation
Knumber of filtering passes

This routine precomputes the coefficients for extended box filtering Gaussian convolution approximation.

Definition at line 35 of file gaussian_conv_ebox.c.