In convolution, the value of an output element is computed as a weighted sum of
neighboring elements.
For example, suppose the first input matrix represents an image and is defined
as:
I1 = [17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9]
The second input matrix also represents an image and is defined as:
The following figure shows how to compute the (1,1) output element by using these
steps:
Rotate the second input matrix, I2, 180 degrees around its
center element.
Slide the center element of I2 so that it lies on top of the
(0,0) element of I1.
Multiply each element of the rotated I2 matrix by the element
of I1 underneath.
Sum the individual products from step 3.
The (1,1) output element is .
The normalized convolution of the (1,1) output element is
220/sqrt(sum(dot(I1p,I1p))*sum(dot(I2,I2)))
= 0.3459, where
I1p = [0 0 0; 0 17 24; 0 23 5]
.