O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Gaussian blur

There is an inbuilt function, GaussianBlur(), which takes the image, dimension of the kernel, and standard deviation as input. If the input standard deviation is zero, then the standard deviation is calculated from the size of the kernel:

>>> import cv2>>> img = cv2.imread("image.jpg")>>> new_img = cv2.GaussianBlur(img,(5,5),0)>>> cv2.imwrite("gaussian_blur.jpg", new_img)>>> cv2.imshow("gaussian_blur.jpg", new_img)

The following figure is the result of applying the Gaussian blur filter:

Figure 9: The original image is on the left and the output is on the right

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required