Image blurring
Image Blurring refers to making the image less clear or distinct. It is done with the help of various low pass filter kernels. Important types of blurring:
- Gaussian Blurring: Gaussian blur is the result of blurring an image by a Gaussian function. It is a widely used effect in graphics software, typically to reduce image noise and reduce detail. It is also used as a preprocessing stage before applying our machine learning or deep learning models. E.g. of a Gaussian kernel(3×3)
- Median Blur: The Median Filter is a non-linear digital filtering technique, often used to remove noise from an image or signal. Median filtering is very widely used in digital image processing because, under certain conditions, it preserves edges while removing noise. It is one of the best algorithms to remove Salt and pepper noise.
- Bilateral Blur: A bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter for images. It replaces the intensity of each pixel with a weighted average of intensity values from nearby pixels. This weight can be based on a Gaussian distribution. Thus, sharp edges are preserved while discarding the weak ones.
Example: Python OpenCV Blur Image
Python3
# importing libraries import cv2 import numpy as np image = cv2.imread( 'geeks.png' ) cv2.imshow( 'Original Image' , image) cv2.waitKey( 0 ) # Gaussian Blur Gaussian = cv2.GaussianBlur(image, ( 7 , 7 ), 0 ) cv2.imshow( 'Gaussian Blurring' , Gaussian) cv2.waitKey( 0 ) # Median Blur median = cv2.medianBlur(image, 5 ) cv2.imshow( 'Median Blurring' , median) cv2.waitKey( 0 ) # Bilateral Blur bilateral = cv2.bilateralFilter(image, 9 , 75 , 75 ) cv2.imshow( 'Bilateral Blurring' , bilateral) cv2.waitKey( 0 ) cv2.destroyAllWindows() |
Output:
Getting Started with Python OpenCV
Computer Vision is one of the techniques from which we can understand images and videos and can extract information from them. It is a subset of artificial intelligence that collects information from digital images or videos.
Python OpenCV is the most popular computer vision library. By using it, one can process images and videos to identify objects, faces, or even handwriting of a human. When it is integrated with various libraries, such as NumPy, python is capable of processing the OpenCV array structure for analysis.
In this article, we will discuss Python OpenCV in detail along with some common operations like resizing, cropping, reading, saving images, etc with the help of good examples.