Extending our discussion on filters from Chapter 3, Image Filtering and Transformations in OpenCV, the convolution operation is taking a dot product of a shifted kernel matrix with a given input image. This process is explained in the following figure:
As shown in the previous figure, a kernel is a small two-dimensional array that computes dot product with the input image (on the left) to create a block of the output image (on the right).
In convolution, the output image is generated by taking a dot product between an Input image and a Kernel matrix. This is then shifted along the image and after each shift, corresponding values of the output are generated using a dot product:
As we saw in the previous chapter, we can perform a convolution operation using OpenCV as follows:
kernel = np.ones((5,5),np.float32)/25
dst = cv2.filter2D(gray,-1...