The CONVOL function convolves an array with a kernel, and returns the result. Convolution is a general process that can be used for various types of smoothing, signal processing, shifting, differentiation, edge detection, etc. The CENTER keyword controls the alignment of the kernel with the array and the ordering of the kernel elements. If CENTER is explicitly set to 0, convolution is performed in the strict mathematical sense, otherwise the kernel is centered over each data point.
Assume R = CONVOL(A, K, S), where A is an n -element vector, K is an m -element vector ( m < n ), and S is the scale factor. If the CENTER keyword is omitted or set to 1:
where the value m /2 is determined by integer division . This means that the result of the division is the largest integer value less than or equal to the fractional number.
If CENTER is explicitly set to 0:
In the two-dimensional, zero CENTER case where A is an m by n -element array, and K is the l by l element kernel; the result R is an m by n -element array:
The centered case is similar, except the t-i and u-j subscripts are replaced by t+i-l /2 and u+j-l /2.
An array of any basic type except string. The result of CONVOL has the same type and dimensions as Array .
If the Array parameter is of byte type, the result is clipped to the range of 0 to 255. Negative results are set to 0, and values greater than 255 are set to 255.
Set or omit this keyword to center the kernel over each array point. If CENTER is explicitly set to zero, the CONVOL function works in the conventional mathematical sense. In many signal and image processing applications, it is useful to center a symmetric kernel over the data, thereby aligning the result with the original array.
Note that for the kernel to be centered, it must be symmetric about the point K(FLOOR( m /2), where m is the number of elements in the kernel.
Set this keyword to make CONVOL compute the values of elements at the edge of Array by "wrapping" the subscripts of Array at the edge. For example, if CENTER is set to zero:
where na is the number of elements in Array .
If neither EDGE_WRAP nor EDGE_TRUNCATE is set, CONVOL sets the values of elements at the edges of Array to zero.
Set this keyword to make CONVOL compute the values of elements at the edge of Array by repeating the subscripts of Array at the edge. For example, if CENTER is set to zero:
where na is the number of elements in Array .
If neither EDGE_WRAP nor EDGE_TRUNCATE is set, CONVOL sets the values of elements at the edges of Array to zero.
Convolve a vector of random noise and a one-dimensional triangular kernel and plot the result. Create a simple vector as the original dataset and plot it by entering:
A = RANDOMN(SEED, 100) & PLOT, A
Create a simple kernel by entering: