0% found this document useful (0 votes)
8 views10 pages

Lab Program 10

sssss

Uploaded by

Vinutha H M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

Lab Program 10

sssss

Uploaded by

Vinutha H M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

10) Write a program to blur and smoothing an image

import cv2 // Import the cv2 module


image = cv2.imread('images.jpg')
blurred_image = cv2.GaussianBlur(image, (15, 15), 0)
cv2.imshow('Original Image', image)
cv2.imshow('Blurred Image', blurred_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Smoothing
• Smoothing in image processing refers to the process
of reducing noise or other unwanted artifacts in an
image while preserving important features and
structures.

• The goal of smoothing is to create a visually


appealing image that is easy to interpret and
analyze.
• Smoothing techniques use filters.
• Different filters used for smoothening are
1. Mean filter
2. Median filter
3. Bilateral filter

4. Gaussian Filter
Gaussian Blur
Syntax:
cv2. GaussianBlur(image, kernelsize, sigmaX )
Image
The image you need to blur
kernelsize
• This parameter specifies the size of the Gaussian kernel
• It should be a tuple (width, height) specifying the kernel
size.
• Both width and height should be odd and positive
numbers.
5 x 5 Kernel
sigmaX

• The Gaussian kernel standard deviation which is the


default set to 0.
blurred_image = cv2.GaussianBlur(image, (15, 15), 0)

cv2. GaussianBlur(image, kernelsize, sigmaX )


Image without noise Image with noise
waitKey()

• waitKey() function of Python OpenCV allows users to


display a window for given milliseconds or until any
key is pressed.

• If 0 is passed in the argument it waits till any key is


pressed.

cv2.waitKey(0)
cv2.destroyAllWindows()
• The function cv2.destroyAllWindows() is used in
OpenCV (cv2) to close all the OpenCV windows that
were created with cv2.imshow().

You might also like