In the preceding code, we are generating different kernels in the code, which are kernel_identity, kernel_3x3, and kernel_5x5. We use the function, filter2D, to apply these kernels to the input image. If you look at the images carefully, you can see that they keep getting blurrier as we increase the kernel size. The reason for this is because when we increase the kernel size, we are averaging over a larger area. This tends to have a larger blurring effect.
An alternative way of doing this would be by using the OpenCV function, blur. If you don't want to generate the kernels yourself, you can just use this function directly. We can call it using the following line of code:
output = cv2.blur(img, (3,3)) ...