#include <dvmkernel.h>
A Kernel is used for convolution of images. The structure contains a matrix and an offset. See the overview for an example of using it. The convolution matrix is stored as a two dimensioanl array of integers. The image is convolved with these values, and the result is scaled by another integer (divfactor). Finally, another integer (offset) is added to the result. This representation allows Dali to perform convolutions using only integer arithmetic.
typedef struct Kernel { int width; int height; int **vals; int divfactor; int offset; } Kernel
- width
- width of the convolution kernel matrix.
- height
- height of the convolution kernel matrix.
- vals
- The matrix, in row-major order.
- divfactor
- Division factor of the vals. The actual values are vals[][]/divfactor
- offset
- Offset applied by the convolution kernel.
Kernel* KernelNew(int width, int height)
Create a new Kernel of the specified width and height and return a pointer to it.
void KernelFree(Kernel *kern)
Free the Kernel pointed to by kern.
KernelSetValues(Kernel *k, int *values)
Set the values of kernel k using the array values. Values is a 1-D array of integers in row major order.
KernelSetDivFactor(Kernel *k, int divfactor)
Set the divfactor slot of Kernel k.
KernelSetOffset(Kernel *k, int offset)
Set the offset slot of Kernel k.
void KernelApply(Kernel *kern, ByteImage *src, ByteImage *dest)
Apply convolution kernel kern to src and put the result into dest. The kernel will be applied only where it can entirely overlap the input; thus, the output will be smaller in each dimension by the corresponding dimension of the kernel. More precisely,
width(dest) = width(src) - width(kern) + 1 height(dest) = height(src) - height(kern) + 1For example, if kern is a 3x3 kernel, and src is a 640x480 image, a region of size 638x478 in dest will be affected. The function ByteExtend() can be used to extend src so that a larger region in dest will be written.void KernelCompose(Kernel *src1, Kernel *src2, Kernel *dest)
Compose src1 and src2, writing the result into dest. dest must have dimensions:
width(dest) = width(src1) + width(src2) - 1 height(dest) = height(src1) + height(src2) - 1
int KernelGetWidth(Kernel *kern)
int KernelGetHeight(Kernel *kern)
int KernelGetDivFactor(Kernel *kern)
int KernelGetOffset(Kernel *kern)
Return the appropriate attribute of the kernel
Last updated : Saturday, November 14, 1998, 07:50 PM