comirva.audio.util.math
Class NormalizedConvolution

java.lang.Object
  extended by comirva.audio.util.math.NormalizedConvolution

public class NormalizedConvolution
extends Object

Normalized Convolution

Description:

This class implements a fast version of the convolution of a filter, represented as a vector, with another vector obtained from a given matrix. For extracting the vector out of the matrix one can specify, if column or row vectors should be used. This is done for all vectors in the matrix.

For example if you like to blur a matrix using a gaussian filter, you hand in the filter and specify, which dimension of the matrix to blur.

Normalized means, that the filter vector used in the constructor will get normalized, such that the sum of the filter weights is 1. Furthermore for the first and the last elements, where one cannot apply the complete filter, a truncated and normalized filter will be used.

The general purpose is to perform the convolution in a fast way and to reuse the convolution object for a large number of convolutions of the same type.


Field Summary
protected  double[] filter
           
 
Constructor Summary
NormalizedConvolution(double[] filter)
          Creates a NormalizedConvolution object, which can be used to compute the convolution a matrix with the given filter by using the convolute() method.
 
Method Summary
 Matrix convolute(Matrix A, boolean firstDimension)
          Perform the convolution of the given matrix according to the specified dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected double[] filter
Constructor Detail

NormalizedConvolution

public NormalizedConvolution(double[] filter)
                      throws IllegalArgumentException
Creates a NormalizedConvolution object, which can be used to compute the convolution a matrix with the given filter by using the convolute() method.

Parameters:
filter - double[] the filter used for the convolution e.g. a gaussian filter
Throws:
IllegalArgumentException - the given filter must not be a null value and must have an odd length greater or equal to 3
Method Detail

convolute

public Matrix convolute(Matrix A,
                        boolean firstDimension)
Perform the convolution of the given matrix according to the specified dimension. The filter has been fixed during the construction of the NormalizedConvolution object.

Parameters:
A - Matrix the matrix to convolute with
firstDimension - boolean if true each of the row vectors will get convoluted with the filter, otherwise each of the column vectors will be used to convolute with
Returns:
Matrix as result the completely convoluted matrix will be returned