Gaussian Blur - ( Drawing and Image Processing in OpenCV )
Heading h2
Syntax
cv2.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]])
Example
import cv2
#reading the image
image = cv2.imread('image.png')
#applying gaussian blur
blurred_image = cv2.GaussianBlur(image, (5 ,5), 0)
#displaying the original and blurred image
cv2.imshow("Original Image", image)
cv2.imshow("Blurred Image", blurred_image)
cv2.waitKey(0)
Output
The output of the above code will display two images, one is the original image and the other is the Gaussian blurred image.
Explanation
Gaussian blur is a commonly used image smoothing algorithm that is used to reduce the amount of noise present in an image. It involves convolving an image with a Gaussian kernel to produce a smoothed image. OpenCV provides the cv2.GaussianBlur()
function to apply Gaussian blur to an image.
In the above example, we read an image using cv2.imread()
function and apply Gaussian blur using cv2.GaussianBlur()
function. We pass the image and kernel size as arguments to the function. The kernel size determines the size of the Gaussian kernel, and the sigma parameter determines the amount of smoothing that is applied to the image.
Use
Gaussian blur is a widely used image processing technique that is used to reduce image noise and improve image quality. It is commonly used in image segmentation, edge detection, and feature detection.
Important Points
- Gaussian blur is a widely used image smoothing technique
- It involves convolving an image with a Gaussian kernel to produce a smoothed image
- OpenCV provides the
cv2.GaussianBlur()
function to apply Gaussian blur to an image - The kernel size and sigma parameters determine the size of the Gaussian kernel and the amount of smoothing applied to the image
Summary
In conclusion, Gaussian blur is a commonly used image processing technique that is used to reduce image noise and improve image quality. The cv2.GaussianBlur()
function in OpenCV is a simple and effective way of applying Gaussian blur to an image. By adjusting the size of the Gaussian kernel and sigma parameter, we can control the amount of smoothing applied to the image.