| ||||||||||||||
| ||||||||||||||
|
||||||||||||||
|
Convolution is a very important operation in image processing. It basically involves calculating the weighted sum of a neighbourhood of pixels. The weights are taken from a convolution kernel. Each value from the neighbourhood of pixels is multiplied with its opposite on the matrix. For example, the top-left of the neighbour is multiplied by the bottom-right of the kernel. All these values are summed up, the this is the result of the convolution. This operation can be mathematically represented as:
A Stepped ExampleBelow is a portion of an image, with a fragment of it highlighted and the greyscale values shown. To the right of that is our convolution kernel (incidentally, one of the Sobel kernels).
N(x,y) = (-1 * 222) +
( 0 * 170) +
( 1 * 149) +
(-2 * 173) +
( 0 * 147) +
( 2 * 205) +
(-1 * 149) +
( 0 * 198) +
( 1 * 221) = 63
CorrelationCorrelation is nearly identical to convolution bar one minor difference:
Computational NotesWhen implementing a convolution or correlation algorithm, there are certain important things you should think about. Firstly, since this a neighbourhood operation, not all pixels in the original image are going to have a complete neighbour (border pixels) so you need a way to deal with these. The most common way is just to ignore them and have an output image slightly smaller than the input. Other techniques include truncating the kernel to process the edge pixels correctly, but this can be complex to implement.The second, most important factor is efficiency. Any programmer will have noticed that the convolution algorithm is naturally costly since it requires retrieval of the neighbourhood, then numerous operations upon that neighbourhood. The most common way to cut down the operation is to take into account the shifting window of operation.
As always, see Image Analysis Explorer Pro for examples and code.
Submitted: 30/08/2002 Article content copyright © James Matthews, 2002.
|
|
|||||||||||||
All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -