Blurring is one of the crucial steps of image preprocessing. In preprocessing, the removal of noise impacts the performance of algorithms. Blurring is the process of reducing noise in image data to achieve better accuracy. Blurring also helps us to take charge of handling pixel intensity.
Let's see an example of blurring an image:
# Import OpenCV module
import cv2
# Import matplotlib for showing the image
import matplotlib.pyplot as plt
# Magic function to render the figure in a notebook
%matplotlib inline
# Read image
image = cv2.imread('tajmahal.jpg')
# Convert image color space BGR to RGB
rgb_image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
# Display the image
plt.imshow(rgb_image)
This results in the following output:
In the preceding code sample, we read the image and converted it from a BGR to RGB based image. Let's blur it using the blur() function. Blur takes two arguments: image and kernel size. The blur() function uses the average blurring method:
# Blur...