util.wavelet
Class SimpleSignal

java.lang.Object
  extended by util.wavelet.SimpleSignal
Direct Known Subclasses:
Signal

public class SimpleSignal
extends Object

A wrapper for an array of signal values and boundary conditions check.

Author:
John Talbot

Constructor Summary
SimpleSignal(float[] values)
          Construct a signal using the given array of signal values and default boundary conditions.
SimpleSignal(float[] values, BoundaryCondition boundaryCondition)
          Construct a signal using the given array of signal values and boundary conditions.
SimpleSignal(int size)
          Construct a zero filled signal using the size and default boundary conditions.
SimpleSignal(int size, BoundaryCondition boundaryCondition)
          Construct a zero filled signal using the size and a boundary condition.
SimpleSignal(SimpleSignal signal)
          Copy constructor.
 
Method Summary
 SimpleSignal add(SimpleSignal signal)
          Add the given signal to this signals and return result in this instance.
static void add(SimpleSignal signalA, SimpleSignal signalB, SimpleSignal signalC)
          Return in 'c' the addition of 'a' and 'b'.
 SimpleSignal convolve(SimpleSignal kernel)
          Convolve this signal with a kernel.
 int estimateNumberOfScales()
          Get an estimate for the number of wavelet scales in this signal.
 BoundaryCondition getBoundaryCondition()
          Get the boundary condition (extrapolation methodology) for this signal.
static SimpleSignal getChirp(int size, float startFrequency, float endFrequency)
          Get a unit amplitude chirp signal with the given start and end frequencies.
static SimpleSignal getDirac(int size)
          Get a dicrete approximation of the Dirac delta function.
static float getGaussianDeviate()
          Get a normally distributed gaussian deviate with zero mean and unit variance.
static SimpleSignal getGaussianNoise(int size)
          Get a unit variance gaussian noise signal.
static SimpleSignal getScalingFunction(int size, float scale)
          Get the B3-spline scaling funtion of the a-trous (with Mirror boundary)
 SimpleSignal getSubset(int start, int end)
          Get a subset of the signal betwen the given start and end positions.
 float getValue(int position)
          Get the signal value at the given position and deal with boundary conditions when position is out of range.
static SimpleSignal getWavelet(int size, float scale)
          Get the B3-spline wavelet funtion of the a-trous (with Mirror boundary)
 SimpleSignal multiply(float multiplier)
          Multiply by the given multipler and return result in this instance.
 SimpleSignal multiply(SimpleSignal signal)
          Multiply by the given signal and return result in this instance.
static void multiply(SimpleSignal signalA, float multiplier, SimpleSignal signalB)
          Return in 'B' the multiplication of 'a' and multiplier.
static void multiply(SimpleSignal signalA, SimpleSignal signalB, SimpleSignal signalC)
          Return in 'c' the multiplication of 'a' and 'b'.
 void setBoundaryCondition(BoundaryCondition boundaryCondition)
          Set the boundary condition (extrapolation methodology) for this signal.
 void setValue(int position, float signalValue)
          Set the signal value at the given position and deal with boundary conditions when position is out of range.
 int size()
          Get the size of this signal.
 SimpleSignal square()
          Square the given signal and return result in this instance.
static void square(SimpleSignal signalA, SimpleSignal signalB)
          Return in 'b' the square of 'a' and 'b'.
 SimpleSignal subtract(SimpleSignal signal)
          Subtract the given signal from this signal and return result in this instance.
static void subtract(SimpleSignal signalA, SimpleSignal signalB, SimpleSignal signalC)
          Return in 'c' the subtraction of 'a' minus 'b'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSignal

public SimpleSignal(float[] values)
Construct a signal using the given array of signal values and default boundary conditions.

Parameters:
values - an array of signal values

SimpleSignal

public SimpleSignal(float[] values,
                    BoundaryCondition boundaryCondition)
Construct a signal using the given array of signal values and boundary conditions.

Parameters:
values - an array of signal values
boundaryCondition - the boundary condition

SimpleSignal

public SimpleSignal(SimpleSignal signal)
Copy constructor.

Parameters:
signal - to be cloned

SimpleSignal

public SimpleSignal(int size)
Construct a zero filled signal using the size and default boundary conditions.

Parameters:
size - the size of the signal

SimpleSignal

public SimpleSignal(int size,
                    BoundaryCondition boundaryCondition)
Construct a zero filled signal using the size and a boundary condition.

Parameters:
size - the size of the signal
boundaryCondition - the boundary condition
Method Detail

convolve

public SimpleSignal convolve(SimpleSignal kernel)
Convolve this signal with a kernel. Not efficient enough for atrous DWT. For symmetric convolutions use only odd sized kernels.

Parameters:
kernel - the convolution kernel

getBoundaryCondition

public BoundaryCondition getBoundaryCondition()
Get the boundary condition (extrapolation methodology) for this signal.

Returns:
the boundary condition;

setBoundaryCondition

public void setBoundaryCondition(BoundaryCondition boundaryCondition)
Set the boundary condition (extrapolation methodology) for this signal.

Parameters:
boundaryCondition - the boundary condition

size

public int size()
Get the size of this signal.

Returns:
size of the signal

getValue

public float getValue(int position)
Get the signal value at the given position and deal with boundary conditions when position is out of range.

Parameters:
position - the position
Returns:
value at the given position or extrapolated value if position is out of range
See Also:
setValue(int, float)

setValue

public void setValue(int position,
                     float signalValue)
Set the signal value at the given position and deal with boundary conditions when position is out of range. Precondition : 0 ≥ index ≤ size().

Parameters:
position - the position
signalValue - the value to set the signal to
See Also:
getValue(int)

getSubset

public SimpleSignal getSubset(int start,
                              int end)
Get a subset of the signal betwen the given start and end positions. The returned signal has the same size as the original signal but with values set to zero for out-of-range positions.

Parameters:
start - position where the subset starts
end - position where the subset ends
Returns:
the subset of this signal in the given range

estimateNumberOfScales

public int estimateNumberOfScales()
Get an estimate for the number of wavelet scales in this signal.

Returns:
the estimated number of wavelet scales contained in this signal, results are garanteed to be greater than zero
See Also:
Scale

getDirac

public static SimpleSignal getDirac(int size)
Get a dicrete approximation of the Dirac delta function. There is an issue with signal having a size which is even : The middle is not defined ! The signal has the value of one at the first position and zero everywhere else and periodic boundary conditions.

Returns:
a dirac function signal

getChirp

public static SimpleSignal getChirp(int size,
                                    float startFrequency,
                                    float endFrequency)
Get a unit amplitude chirp signal with the given start and end frequencies.

Parameters:
size - the size of the signal
startFrequency - the starting frequency (in units of sample size)
endFrequency - the ending frequency (in units of sample size)
Returns:
the chirp

getGaussianNoise

public static SimpleSignal getGaussianNoise(int size)
Get a unit variance gaussian noise signal.

Parameters:
size - the size of the signal
Returns:
the gaussian noise signal

getGaussianDeviate

public static float getGaussianDeviate()
Get a normally distributed gaussian deviate with zero mean and unit variance. (see function gasdev(long *idnum) in Press (1992) Numerical Recipes in C, 2nd ed. page 289)

Returns:
a number roughly between -1 and +1

getScalingFunction

public static SimpleSignal getScalingFunction(int size,
                                              float scale)
Get the B3-spline scaling funtion of the a-trous (with Mirror boundary)

Returns:
a scaling function

getWavelet

public static SimpleSignal getWavelet(int size,
                                      float scale)
Get the B3-spline wavelet funtion of the a-trous (with Mirror boundary)

Returns:
a wavelet function

add

public SimpleSignal add(SimpleSignal signal)
Add the given signal to this signals and return result in this instance. Precondition: signal must be non-null and equal in size to this signal

Parameters:
signal - the signal to be added

subtract

public SimpleSignal subtract(SimpleSignal signal)
Subtract the given signal from this signal and return result in this instance. Precondition: signal must be non-null and equal in size to this signal

Parameters:
signal - the signal to be subtracted

multiply

public SimpleSignal multiply(SimpleSignal signal)
Multiply by the given signal and return result in this instance. Precondition: signal must be non-null and equal in size to this signal

Parameters:
signal - the signal to be multiplied

multiply

public SimpleSignal multiply(float multiplier)
Multiply by the given multipler and return result in this instance. Precondition: signal must be non-null and equal in size to this signal

Parameters:
multiplier - the multiplier

square

public SimpleSignal square()
Square the given signal and return result in this instance. Precondition: signal must be non-null and equal in size to this signal


add

public static void add(SimpleSignal signalA,
                       SimpleSignal signalB,
                       SimpleSignal signalC)
Return in 'c' the addition of 'a' and 'b'.

Parameters:
signalA - input
signalB - input
signalC - output equals signalA + signalB

subtract

public static void subtract(SimpleSignal signalA,
                            SimpleSignal signalB,
                            SimpleSignal signalC)
Return in 'c' the subtraction of 'a' minus 'b'.

Parameters:
signalA - input
signalB - input
signalC - output equals signalA - signalB

multiply

public static void multiply(SimpleSignal signalA,
                            SimpleSignal signalB,
                            SimpleSignal signalC)
Return in 'c' the multiplication of 'a' and 'b'.

Parameters:
signalA - input
signalB - input
signalC - output equals signalA * signalB

multiply

public static void multiply(SimpleSignal signalA,
                            float multiplier,
                            SimpleSignal signalB)
Return in 'B' the multiplication of 'a' and multiplier.

Parameters:
signalA - input
multiplier - input
signalB - output equals signalA * multiplier

square

public static void square(SimpleSignal signalA,
                          SimpleSignal signalB)
Return in 'b' the square of 'a' and 'b'.

Parameters:
signalA - input
signalB - output equals signalA*signalA