Page 268 - AI Ver 1.0 Class 10
P. 268
In simple terms, convolution is passing a "kernel" matrix over the whole "image" matrix to give the convoluted
matrix i.e., the filtered image.
Technically, convolution is defined as a simple Mathematical operation that multiplies two numeric arrays of
the same dimensions but different sizes to produce a third numeric array of the same dimensions. For example:
12 11 81 57 86 87 45 68
23 22 90 56 35 54 12 22
45 37 91 54 85 25 23 79 12 11 81 103
40 78 69 58 34 74 90 97 × 23 22 90 =
12 89 68 90 78 24 68 42 45 37 91
34 92 61 43 66 96 23 24
18 56 41 24 56 45 44 66
19 67 61 77 23 99 77 23
Image Matrix Kernel Matrix Convoluted Matrix/Desired image
A B C
The resulting pixel value is calculated as:
(56 × 1) + (35 × 0) + (54 × –1) + (54 × 0) + (85 × 1) + (25 × 0) + (58 × –1) + (34 × 0) + (74 × 1) = 103
Kernel
Kernel is also known as a convolution matrix or mask (typically a 3x3 or 5x5 matrix) will help you in image
processing by creating a wide range of effects like sharp, blur, masking etc. The kernel is slid across the image
and multiplied with the input image matrix to generate an output image with an enhanced desired effect.
In the process of doing it, along the edges of the input image, the top left corner has only three neighbors so the
output image becomes smaller. If we want the output image to be of exact size of the input image then during
the process of overlapping the centers of the input image and the kernel, extend the edge values out by one in
the input image. The pixel value is 0 when edges are extended.
For example, if 3X3 kernel is used to calculate each pixel, the Kernel filter is multiplied with the current overlapping
pixel value and the other 8 surrounding pixels. Then the result of the multiplication is added up to generate the
value of the current pixel.
(4 × 0)
(0 × 0)
Center element of the kernel is placed over the (0 × 0)
source pixel. The source pixel is then replaced with (0 × 0)
a weighted sum of itself and nearby pixels. (0 × 1)
(0 × 1)
Source pixel (0 × 0)
(0 × 1)
+ (– 4 × 2)
– 8
Convolution kernel
(emboss)
New pixel value (destination pixel)
How kernel is applied to an image to extract features
266 Touchpad Artificial Intelligence-X

