The convolution of two continuous signals and is defined as
Convolution in discrete form is
If the system in question were a causal system in time domain
If is symmetric (almost always true in image processing),
then replacing by we get
If the input is finite (always true in reality), i.e.,
Digital convolution can be best understood graphically (where the index of is rearranged) as shown below:
Assume the size of the input signal is ( ) and the size of is (usually an odd number), then the size of the resulting convolution is . However, as it is usually desirable for the output to have the same size as the input , we can drop components at each end of . When the size of is even, we can drop components at one end and from the other of .
The code segment for this 1D convolution is given below.
In particular, if the elements of the kernel are all the same (an average operator or a low-pass filter), the we can speed up the convolution process while sliding the kernel over the input signal by taking care of only the two ends of the kernel.
In image processing, all of the discussions above for one-dimensional convolution are generalized into two dimensions, and is called a convolution kernel, or mask.