public class Conv
extends java.lang.Object
Convolution of one-dimensional sequences x and y is defined generically by the following sum:
z[i] = sum x[j]*y[i-j]
j
In practice, the sequences x, y, and z are non-zero for only finite
ranges of sample indices i and j, and these ranges determine limits
on the summation index j.
Specifically, the sequences x, y, and z are stored in arrays with zero-based indexing; e.g., x[0], x[1], x[2], ..., x[lx-1], where lx denotes the length of the array x. Sequences are assumed to be zero for indices outside the bounds of these arrays.
Note that an array index need not equal its corresponding sample index. For each sequence, we must specify the sample index of the first sample in the array of sample values; e.g., kx denotes the sample index of x[0]. With this distinction between sample and array indices in mind, in terms of arrays x, y, and z, the convolution sum may be rewritten as
jhi
z[i-k] = sum x[j]*y[i-j] ; i = k, k+1, ..., k+lz-1
j=jlo
where k = kz-kx-ky, jlo = max(0,i-ly+1), and jhi = min(lx-1,i). The
summation limits jlo and jhi ensure that array indices are always in
bounds. The effect of the three first-sample indices is encoded in the
single shift k.
For example, if sequence z is to be a weighted average of the nearest five samples of sequence y, one might use
...
x[0] = x[1] = x[2] = x[3] = x[4] = 1.0/5.0;
conv(5,-2,x,ly,0,y,ly,0,z);
...
In this example, the sequence x is symmetric about the origin, with
first-sample index kx = -2.
Cross-correlation is similar to convolution. (Indeed, cross-correlation of x and y equals the convolution of x-reversed and y. The generic definition of cross-correlation is
z[i] = sum x[j]*y[i+j]
j
Unlike convolution, cross-correlation is not commutative. In other words,
the cross-correlation of x and y does not equal the cross-correlation of
y and x.Constructor and Description |
---|
Conv() |
Modifier and Type | Method and Description |
---|---|
static void |
conv(int lx,
int kx,
float[] x,
int ly,
int ky,
float[] y,
int lz,
int kz,
float[] z)
Computes the 1-D convolution of specified sequences x and y.
|
static void |
conv(int lx1,
int lx2,
int kx1,
int kx2,
float[][] x,
int ly1,
int ly2,
int ky1,
int ky2,
float[][] y,
int lz1,
int lz2,
int kz1,
int kz2,
float[][] z)
Computes the 2-D convolution of specified sequences x and y.
|
static void |
conv(int lx1,
int lx2,
int lx3,
int kx1,
int kx2,
int kx3,
float[][][] x,
int ly1,
int ly2,
int ly3,
int ky1,
int ky2,
int ky3,
float[][][] y,
int lz1,
int lz2,
int lz3,
int kz1,
int kz2,
int kz3,
float[][][] z)
Computes the 3-D convolution of specified sequences x and y.
|
static void |
xcor(int lx,
int kx,
float[] x,
int ly,
int ky,
float[] y,
int lz,
int kz,
float[] z)
Computes the 1-D cross-correlation of specified sequences x and y.
|
static void |
xcor(int lx1,
int lx2,
int kx1,
int kx2,
float[][] x,
int ly1,
int ly2,
int ky1,
int ky2,
float[][] y,
int lz1,
int lz2,
int kz1,
int kz2,
float[][] z)
Computes the 2-D cross-correlation of specified sequences x and y.
|
static void |
xcor(int lx1,
int lx2,
int lx3,
int kx1,
int kx2,
int kx3,
float[][][] x,
int ly1,
int ly2,
int ly3,
int ky1,
int ky2,
int ky3,
float[][][] y,
int lz1,
int lz2,
int lz3,
int kz1,
int kz2,
int kz3,
float[][][] z)
Computes the 3-D cross-correlation of specified sequences x and y.
|
public static void conv(int lx, int kx, float[] x, int ly, int ky, float[] y, int lz, int kz, float[] z)
lx
- the length of x.kx
- the sample index of x[0].x
- array[lx] of x values.ly
- the length of y.ky
- the sample index of y[0].y
- array[ly] of y values.lz
- the length of z.kz
- the sample index of z[0].z
- array[lz] of z values.public static void conv(int lx1, int lx2, int kx1, int kx2, float[][] x, int ly1, int ly2, int ky1, int ky2, float[][] y, int lz1, int lz2, int kz1, int kz2, float[][] z)
lx1
- the length of x in 1st dimension.lx2
- the length of x in 2nd dimension.kx1
- the sample index in 1st dimension of x[0][0].kx2
- the sample index in 2nd dimension of x[0][0].x
- array[lx2][lx1] of x values.ly1
- the length of y in 1st dimension.ly2
- the length of y in 2nd dimension.ky1
- the sample index in 1st dimension of y[0][0].ky2
- the sample index in 2nd dimension of y[0][0].y
- array[ly2][ly1] of y values.lz1
- the length of z in 1st dimension.lz2
- the length of z in 2nd dimension.kz1
- the sample index in 1st dimension of z[0][0].kz2
- the sample index in 2nd dimension of z[0][0].z
- array[lz2][lz1] of z values.public static void conv(int lx1, int lx2, int lx3, int kx1, int kx2, int kx3, float[][][] x, int ly1, int ly2, int ly3, int ky1, int ky2, int ky3, float[][][] y, int lz1, int lz2, int lz3, int kz1, int kz2, int kz3, float[][][] z)
lx1
- the length of x in 1st dimension.lx2
- the length of x in 2nd dimension.lx3
- the length of x in 3rd dimension.kx1
- the sample index in 1st dimension of x[0][0][0].kx2
- the sample index in 2nd dimension of x[0][0][0].kx3
- the sample index in 3rd dimension of x[0][0][0].x
- array[lx3][lx2][lx1] of x values.ly1
- the length of y in 1st dimension.ly2
- the length of y in 2nd dimension.ly3
- the length of y in 3rd dimension.ky1
- the sample index in 1st dimension of y[0][0][0].ky2
- the sample index in 2nd dimension of y[0][0][0].ky3
- the sample index in 3rd dimension of y[0][0][0].y
- array[ly3][ly2][ly1] of y values.lz1
- the length of z in 1st dimension.lz2
- the length of z in 2nd dimension.lz3
- the length of z in 3rd dimension.kz1
- the sample index in 1st dimension of z[0][0][0].kz2
- the sample index in 2nd dimension of z[0][0][0].kz3
- the sample index in 3rd dimension of z[0][0][0].z
- array[lz3][lz2][lz1] of z values.public static void xcor(int lx, int kx, float[] x, int ly, int ky, float[] y, int lz, int kz, float[] z)
lx
- the length of x.kx
- the sample index of x[0].x
- array[lx] of x values.ly
- the length of y.ky
- the sample index of y[0].y
- array[ly] of y values.lz
- the length of z.kz
- the sample index of z[0].z
- array[lz] of z values.public static void xcor(int lx1, int lx2, int kx1, int kx2, float[][] x, int ly1, int ly2, int ky1, int ky2, float[][] y, int lz1, int lz2, int kz1, int kz2, float[][] z)
lx1
- the length of x in 1st dimension.lx2
- the length of x in 2nd dimension.kx1
- the sample index in 1st dimension of x[0][0].kx2
- the sample index in 2nd dimension of x[0][0].x
- array[lx2][lx1] of x values.ly1
- the length of y in 1st dimension.ly2
- the length of y in 2nd dimension.ky1
- the sample index in 1st dimension of y[0][0].ky2
- the sample index in 2nd dimension of y[0][0].y
- array[ly2][ly1] of y values.lz1
- the length of z in 1st dimension.lz2
- the length of z in 2nd dimension.kz1
- the sample index in 1st dimension of z[0][0].kz2
- the sample index in 2nd dimension of z[0][0].z
- array[lz2][lz1] of z values.public static void xcor(int lx1, int lx2, int lx3, int kx1, int kx2, int kx3, float[][][] x, int ly1, int ly2, int ly3, int ky1, int ky2, int ky3, float[][][] y, int lz1, int lz2, int lz3, int kz1, int kz2, int kz3, float[][][] z)
lx1
- the length of x in 1st dimension.lx2
- the length of x in 2nd dimension.lx3
- the length of x in 3rd dimension.kx1
- the sample index in 1st dimension of x[0][0][0].kx2
- the sample index in 2nd dimension of x[0][0][0].kx3
- the sample index in 3rd dimension of x[0][0][0].x
- array[lx3][lx2][lx1] of x values.ly1
- the length of y in 1st dimension.ly2
- the length of y in 2nd dimension.ly3
- the length of y in 3rd dimension.ky1
- the sample index in 1st dimension of y[0][0][0].ky2
- the sample index in 2nd dimension of y[0][0][0].ky3
- the sample index in 3rd dimension of y[0][0][0].y
- array[ly3][ly2][ly1] of y values.lz1
- the length of z in 1st dimension.lz2
- the length of z in 2nd dimension.lz3
- the length of z in 3rd dimension.kz1
- the sample index in 1st dimension of z[0][0][0].kz2
- the sample index in 2nd dimension of z[0][0][0].kz3
- the sample index in 3rd dimension of z[0][0][0].z
- array[lz3][lz2][lz1] of z values.