edu.mines.jtk.dsp
Class RecursiveGaussianFilter

java.lang.Object
  extended by edu.mines.jtk.dsp.RecursiveGaussianFilter

public class RecursiveGaussianFilter
extends java.lang.Object

Recursive implementation of a Gaussian filter and derivatives. Filters include the 0th, 1st, and 2nd derivatives. The impulse response of the 0th-derivative smoothing filter is infinitely long, and is approximately h[n] = 1.0/(sqrt(2*PI)*sigma)*exp(-0.5*(n*n)/(sigma*sigma)). Here, sigma denotes the standard width of the Gaussian.

For large filter widths sigma, this recursive implementation can be much more efficient than convolution with a truncated Gaussian. Specifically, if the Gaussian is truncated for |n| > 4*sigma, then this recursive implementation requires 2/sigma of the multiplications required by convolution. In other words, for sigma > 2, this recursive implementation should be more efficient than convolution.

For any application of this filter, input and output arrays may be the same array. When the filter cannot be applied in-place, intermediate arrays are constructed internally.

This filter implements two different methods for approximating with difference equations a Gaussian filter and its derivatives.

The first method is that of Deriche, R., 1993, Recursively implementing the Gaussian and its derivatives: INRIA Research Report, number 1893. Deriche's method is used for small widths sigma, for which it is most accurate.

The second method is that of van Vliet, L.J., Young, I.T., and Verbeek, P.W., 1998, Recursive Gaussian derivative filters, Proceedings of the 14th International Conference on Pattern Recognition, IEEE Computer Society Press. The parallel implementation used here yields zero-phase impulse responses without the end effects caused by the serial (cascade) poles-only implementation recommended by van Vliet, et al. This second method is used for large widths sigma.

Version:
2006.02.12
Author:
Dave Hale, Colorado School of Mines

Nested Class Summary
static class RecursiveGaussianFilter.Method
          The method used to design the Gaussian filter.
 
Constructor Summary
RecursiveGaussianFilter(double sigma)
          Construct a Gaussian filter with specified width.
RecursiveGaussianFilter(double sigma, RecursiveGaussianFilter.Method method)
          Construct a Gaussian filter with specified width and design method.
 
Method Summary
 void apply0(float[] x, float[] y)
          Applies the 0th-derivative filter.
 void apply00(float[][] x, float[][] y)
          Applies the 0th-derivative filter along the 1st and 2nd dimensions.
 void apply000(float[][][] x, float[][][] y)
          Applies the 0th-derivative filter along the 1st, 2nd and 3rd dimensions.
 void apply001(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 3rd dimension and the 0th-derivative filter along the 1st and 2nd dimensions.
 void apply002(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 3rd dimension and the 0th-derivative filter along the 1st and 2nd dimensions.
 void apply01(float[][] x, float[][] y)
          Applies the 0th-derivative filter along the 1st dimension and the 1st-derivative filter along the 2nd dimension.
 void apply010(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 2nd dimension and the 0th-derivative filter along the 1st and 3rd dimensions.
 void apply011(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 2nd and 3rd dimensions and the 0th-derivative filter along the 1st dimension.
 void apply02(float[][] x, float[][] y)
          Applies the 0th-derivative filter along the 1st dimension and the 2nd-derivative filter along the 2nd dimension.
 void apply020(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 2nd dimension and the 0th-derivative filter along the 1st and 3rd dimensions.
 void apply0X(float[][] x, float[][] y)
          Applies the 0th-derivative filter along the 1st dimension.
 void apply0XX(float[][][] x, float[][][] y)
          Applies the 0th-derivative filter along the 1st dimension.
 void apply1(float[] x, float[] y)
          Applies the 1st-derivative filter.
 void apply10(float[][] x, float[][] y)
          Applies the 1st-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd dimension.
 void apply100(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd and 3rd dimensions.
 void apply101(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 1st and 3rd dimensions and the 0th-derivative filter along the 2nd dimension.
 void apply11(float[][] x, float[][] y)
          Applies the 1st-derivative filter along the 1st and 2nd dimensions.
 void apply110(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 1st and 2nd dimensions and the 0th-derivative filter along the 3rd dimension.
 void apply1X(float[][] x, float[][] y)
          Applies the 1st-derivative filter along the 1st dimension.
 void apply1XX(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 1st dimension.
 void apply2(float[] x, float[] y)
          Applies the 2nd-derivative filter.
 void apply20(float[][] x, float[][] y)
          Applies the 2nd-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd dimension.
 void apply200(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd and 3rd dimensions.
 void apply2X(float[][] x, float[][] y)
          Applies the 2nd-derivative filter along the 1st dimension.
 void apply2XX(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 1st dimension.
 void applyX0(float[][] x, float[][] y)
          Applies the 0th-derivative filter along the 2nd dimension.
 void applyX0X(float[][][] x, float[][][] y)
          Applies the 0th-derivative filter along the 2nd dimension.
 void applyX1(float[][] x, float[][] y)
          Applies the 1st-derivative filter along the 2nd dimension.
 void applyX1X(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 2nd dimension.
 void applyX2(float[][] x, float[][] y)
          Applies the 2nd-derivative filter along the 2nd dimension.
 void applyX2X(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 2nd dimension.
 void applyXX0(float[][][] x, float[][][] y)
          Applies the 0th-derivative filter along the 3rd dimension.
 void applyXX1(float[][][] x, float[][][] y)
          Applies the 1st-derivative filter along the 3rd dimension.
 void applyXX2(float[][][] x, float[][][] y)
          Applies the 2nd-derivative filter along the 3rd dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecursiveGaussianFilter

public RecursiveGaussianFilter(double sigma,
                               RecursiveGaussianFilter.Method method)
Construct a Gaussian filter with specified width and design method.

Parameters:
sigma - the width; must not be less than 1.
method - the method used to design the filter.

RecursiveGaussianFilter

public RecursiveGaussianFilter(double sigma)
Construct a Gaussian filter with specified width.

Parameters:
sigma - the width; must not be less than 1.
Method Detail

apply0

public void apply0(float[] x,
                   float[] y)
Applies the 0th-derivative filter.

Parameters:
x - the filter input.
y - the filter output.

apply1

public void apply1(float[] x,
                   float[] y)
Applies the 1st-derivative filter.

Parameters:
x - the filter input.
y - the filter output.

apply2

public void apply2(float[] x,
                   float[] y)
Applies the 2nd-derivative filter.

Parameters:
x - the filter input.
y - the filter output.

apply0X

public void apply0X(float[][] x,
                    float[][] y)
Applies the 0th-derivative filter along the 1st dimension. Applies no filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply1X

public void apply1X(float[][] x,
                    float[][] y)
Applies the 1st-derivative filter along the 1st dimension. Applies no filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply2X

public void apply2X(float[][] x,
                    float[][] y)
Applies the 2nd-derivative filter along the 1st dimension. Applies no filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

applyX0

public void applyX0(float[][] x,
                    float[][] y)
Applies the 0th-derivative filter along the 2nd dimension. Applies no filter along the 1st dimension.

Parameters:
x - the filter input.
y - the filter output.

applyX1

public void applyX1(float[][] x,
                    float[][] y)
Applies the 1st-derivative filter along the 2nd dimension. Applies no filter along the 1st dimension.

Parameters:
x - the filter input.
y - the filter output.

applyX2

public void applyX2(float[][] x,
                    float[][] y)
Applies the 2nd-derivative filter along the 2nd dimension. Applies no filter along the 1st dimension.

Parameters:
x - the filter input.
y - the filter output.

apply0XX

public void apply0XX(float[][][] x,
                     float[][][] y)
Applies the 0th-derivative filter along the 1st dimension. Applies no filter along the 2nd or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply1XX

public void apply1XX(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 1st dimension. Applies no filter along the 2nd or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply2XX

public void apply2XX(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 1st dimension. Applies no filter along the 2nd or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyX0X

public void applyX0X(float[][][] x,
                     float[][][] y)
Applies the 0th-derivative filter along the 2nd dimension. Applies no filter along the 1st or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyX1X

public void applyX1X(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 2nd dimension. Applies no filter along the 1st or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyX2X

public void applyX2X(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 2nd dimension. Applies no filter along the 1st or 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyXX0

public void applyXX0(float[][][] x,
                     float[][][] y)
Applies the 0th-derivative filter along the 3rd dimension. Applies no filter along the 1st or 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyXX1

public void applyXX1(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 3rd dimension. Applies no filter along the 1st or 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

applyXX2

public void applyXX2(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 3rd dimension. Applies no filter along the 1st or 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply00

public void apply00(float[][] x,
                    float[][] y)
Applies the 0th-derivative filter along the 1st and 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply10

public void apply10(float[][] x,
                    float[][] y)
Applies the 1st-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply01

public void apply01(float[][] x,
                    float[][] y)
Applies the 0th-derivative filter along the 1st dimension and the 1st-derivative filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply11

public void apply11(float[][] x,
                    float[][] y)
Applies the 1st-derivative filter along the 1st and 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply20

public void apply20(float[][] x,
                    float[][] y)
Applies the 2nd-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply02

public void apply02(float[][] x,
                    float[][] y)
Applies the 0th-derivative filter along the 1st dimension and the 2nd-derivative filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply000

public void apply000(float[][][] x,
                     float[][][] y)
Applies the 0th-derivative filter along the 1st, 2nd and 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply100

public void apply100(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd and 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply010

public void apply010(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 2nd dimension and the 0th-derivative filter along the 1st and 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply001

public void apply001(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 3rd dimension and the 0th-derivative filter along the 1st and 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply110

public void apply110(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 1st and 2nd dimensions and the 0th-derivative filter along the 3rd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply101

public void apply101(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 1st and 3rd dimensions and the 0th-derivative filter along the 2nd dimension.

Parameters:
x - the filter input.
y - the filter output.

apply011

public void apply011(float[][][] x,
                     float[][][] y)
Applies the 1st-derivative filter along the 2nd and 3rd dimensions and the 0th-derivative filter along the 1st dimension.

Parameters:
x - the filter input.
y - the filter output.

apply200

public void apply200(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 1st dimension and the 0th-derivative filter along the 2nd and 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply020

public void apply020(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 2nd dimension and the 0th-derivative filter along the 1st and 3rd dimensions.

Parameters:
x - the filter input.
y - the filter output.

apply002

public void apply002(float[][][] x,
                     float[][][] y)
Applies the 2nd-derivative filter along the 3rd dimension and the 0th-derivative filter along the 1st and 2nd dimensions.

Parameters:
x - the filter input.
y - the filter output.