Working with kernels
Now, let's learn about kernels. We will learn how to use kernels for signal and image processing operations. Kernels are square numerical matrices. Depending on the size and components of the kernel, if we convolve the kernel with the image, we get blurred or sharpened output. Kernels are used for a variety of image processing operations.
Let's look at an example of a simple kernel used for averaging. It can be represented with the following formula:
By using the preceding formula, an averaging kernel that's 3x3 in size can be expressed as follows:
The value of the number of rows and the number of columns is always odd and always the same. They are all square matrices.
We can use the following NumPy code to create the preceding kernel:
K = np.ones((3, 3), np.uint8)/9
Now, we'll learn how to use the preceding kernel and other kernels to process the sample images from the dataset...