How to blur an image in OpenCV Python

share link

by ganesh dot icon Updated: Jul 25, 2023

technology logo
technology logo

Solution Kit Solution Kit  

Digital image processing uses image blurring. It helps in removing graining from an image, improving the quality of the image, and blurring the background. 

An open-source and free library of computer vision and machine learning methods is called OpenCV (Open-Source Computer Vision). It is employed in several procedures, including object identification, image stitching, and video stabilization. Although it is written in C++, it provides interfaces for other programming languages like Python, Java, and C#. OpenCV is frequently employed in academic and commercial projects and is available for Windows, Linux, and macOS. To make an image blurry, you can use the GaussianBlur() method of OpenCV.

OpenCV-Python uses Numpy, a highly efficient library for numerical operations with a MATLAB-like syntax. Numpy arrays are translated into and out of all OpenCV array forms. The GaussianBlur() function uses the Gaussian kernel. The height and width of the kernel should be a positive and an odd number. Then you must specify the X and Y directions, which are sigmaX and sigmaY, respectively. If only one is specified, both are considered the same.

Here is an example of how you might use this function to make an image blurry: