etutorialspoint
  • Home
  • PHP
  • MySQL
  • MongoDB
  • HTML
  • Javascript
  • Node.js
  • Express.js
  • Python
  • Jquery
  • R
  • Kotlin
  • DS
  • Blogs
  • Theory of Computation

Python OpenCV Gaussian Blur Filtering

In this article, you will learn about the image noises, different techniques to filter them, especially about the Python OpenCV Gaussian Blur filter and how this is useful to filter image.

Python OpenCV has several filtering techniques to perform smoothing operations on images, like - Gaussian Filtering, Median Filtering, Bilateral Filtering. Images can contain different types of noise, especially because of camera sensor. These smoothing techniques are generally used to reduce noise, reduce detail, and so on.

At the point when individuals see a picture, we see what it represents. In the given image, we see a beautiful nature scene. If we notice it all the more carefully, we will see it contain lot of color. But, a computer looks this differently than people does. From a computational point of view, this image is just a large 2-dimensional matrix of numbers. Each number speaks to the color of a pixel. The computer can deal with these 2-D matrices by applying different functions to them to adjust the qualities.

Python Gausssian Image

Here, we have used Gaussian Filter. The Gaussian Filter is a low pass filter. The Gaussian smoothing (or blur) of an image removes the outlier pixels or the high-frequency components to reduce noise. It is likewise utilized as a preprocessing stage prior to applying our AI or deep learning models.

The OpenCV Gaussian filtering provides cv2.GaussianBlur() method to blur an image by using Gaussian Kernel. Each pixel in an image gets multiplied by Gaussian Kernel. It means, a Gaussian Kernel is a square array of pixels.


Syntax of GaussianBlur()
cv2.GaussianBlur(src, ksize, sigma_x, dst, sigma_y, border_type)

  • src - the input image,
  • ksize - Gaussian kernel size (width and height), the width and height can have different values and must be positive and odd,
  • sigma_x - Gaussian kernel standard deviation along X-axis,
  • dst - output image,
  • sigma_y - Gaussian kernel standard deviation along Y-axis,
  • border_type - image boundaries. Possible values are - BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101, BORDER_TRANSPARENT, BORDER_REFLECT101, BORDER_DEFAULT, BORDER_ISOLATED

The size of the sigma specifies how wide the curve should be inside the kernel. If only sigma_x is specified, sigma_y is automatically taken as equal to sigma_x. If both are defined as zeros, they are calculated from the kernel size.





Example1 of Gaussian Blur

The given code blurs the image using the Gaussian kernel of size (5,5) and BORDER_DEFAULT as the border type -

import cv2
import numpy
  
# image path 
path = r'nature.jpg'

# using imread()  
img = cv2.imread(path)

dst = cv2.GaussianBlur(img,(5,5),cv2.BORDER_DEFAULT) 

cv2.imshow('image', numpy.hstack((img, dst)))
cv2.waitKey(0);
cv2.destroyAllWindows();
cv2.waitKey(1)

The above code returns blurred image of n-dimensional array in output.

Python Gausssian Image



Example2 of Gaussian Blur

The following line of code blurs the image using the Gaussian kernel of size (9,9) and BORDER_REFLECT_101 as border type -

import cv2
import numpy
  
# image path 
path = r'nature.jpg'

# using imread()  
img = cv2.imread(path)

dst = cv2.GaussianBlur(img,(9,9),cv2.BORDER_REFLECT_101) 

cv2.imshow('image', numpy.hstack((img, dst)))
cv2.waitKey(0);
cv2.destroyAllWindows();
cv2.waitKey(1)

Output of the above code -

Python Gausssian Image



Related Articles

Python OpenCV Overview and Examples
Draw different shapes on image using Python OpenCV
How to convert MySQL query result to JSON in Python
How to display data from MongoDB in HTML table using Python
CRUD operations in Python using MongoDB connector
Write Python Pandas Dataframe to CSV
Quick Introduction to Python Pandas
Python Pandas DataFrame
Python3 Tkinter Messagebox
Python get visitor information by IP address
Python Webbrowser
Python Tkinter Overview and Examples
Python Turtle Graphics Overview




Most Popular Development Resources
Characteristics of a Good Computer Program
-----------------
Retrieve Data From Database Without Page refresh Using AJAX, PHP and Javascript
-----------------
PHP MySQL PDO Database Connection and CRUD Operations
-----------------
How to get data from XML file in PHP
-----------------
Hypertext Transfer Protocol Overview
-----------------
PHP Create Word Document from HTML
-----------------
PHP code to send email using SMTP
-----------------
How to encrypt password in PHP
-----------------
Create Dynamic Pie Chart using Google API, PHP and MySQL
-----------------
Splitting MySQL Results Into Two Columns Using PHP
-----------------
How to get current directory, filename and code line number in PHP
-----------------
Dynamically Add/Delete HTML Table Rows Using Javascript
-----------------
Get current visitor\'s location using HTML5 Geolocation API and PHP
-----------------
How to Sort Table Data in PHP and MySQL
-----------------
PHP MYSQL Advanced Search Feature
-----------------
Simple star rating system using PHP, jQuery and Ajax
-----------------
Simple pagination in PHP with MySQL
-----------------
Fibonacci Series Program in PHP
-----------------
jQuery loop over JSON result after AJAX Success
-----------------
How to add multiple custom markers on google map
-----------------
PHP user registration and login/ logout with secure password encryption
-----------------
Submit a form data using PHP, AJAX and Javascript
-----------------
Recover forgot password using PHP7 and MySQLi
-----------------
Php file based authentication
-----------------
PHP Secure User Registration with Login/logout
-----------------
jQuery File upload progress bar with file size validation
-----------------
Polling system using PHP, Ajax and MySql
-----------------
Simple PHP File Cache
-----------------
SQL Injection Prevention Techniques
-----------------
Simple File Upload Script in PHP
-----------------
CSS Simple Menu Navigation Bar
-----------------
PHP User Authentication by IP Address
-----------------
Preventing Cross Site Request Forgeries(CSRF) in PHP
-----------------
How to generate QR Code in PHP
-----------------
Calculate the distance between two locations using PHP
-----------------
Simple way to send SMTP mail using Node.js
-----------------
Detect Mobile Devices in PHP
-----------------
Set and Get Cookies in PHP
-----------------
To check whether a year is a leap year or not in php
-----------------
PHP Server Side Form Validation
-----------------
Date Timestamp Formats in PHP
-----------------
Get Visitor\'s location and TimeZone
-----------------
Simple Show Hide Menu Navigation
-----------------
Convert MySQL to JSON using PHP
-----------------
PHP Programming Error Types
-----------------
PHP Sending HTML form data to an Email
-----------------
Driving route directions from source to destination using HTML5 and Javascript
-----------------
How to print specific part of a web page in javascript
-----------------
Google Street View API Example
-----------------
How to select/deselect all checkboxes using Javascript
-----------------
How to add google map on your website and display address on click marker
-----------------
PHP Getting Document of Remote Address
-----------------
PHP Connection and File Handling on FTP Server
-----------------
File Upload Validation in PHP
-----------------
R Plot Types
-----------------


Most Popular Blogs
Most in demand programming languages
Best mvc PHP frameworks in 2019
MariaDB vs MySQL
Most in demand NoSQL databases for 2019
Best AI Startups In India
Kotlin : Android App Development Choice
Kotlin vs Java which one is better
Top Android App Development Languages in 2019
Web Robots
Data Science Recruitment of Freshers - 2019


Interview Questions Answers
Basic PHP Interview
Advanced PHP Interview
MySQL Interview
Javascript Interview
HTML Interview
CSS Interview
Programming C Interview
Programming C++ Interview
Java Interview
Computer Networking Interview
NodeJS Interview
ExpressJS Interview
R Interview


Popular Tutorials
PHP Tutorial (Basic & Advance)
MySQL Tutorial & Exercise
MongoDB Tutorial
Python Tutorial & Exercise
Kotlin Tutorial & Exercise
R Programming Tutorial
HTML Tutorial
jQuery Tutorial
NodeJS Tutorial
ExpressJS Tutorial
Theory of Computation Tutorial
Data Structure Tutorial
Javascript Tutorial




General Knowledge

listen
listen
listen
listen
listen
listen
listen
listen
listen


Learn Popular Language

listen
listen
listen
listen
listen

Blogs

  • Jan 27

    Best AI Startups In India

    Artificial Intelligence is a process of making an intelligent computer machine that does tasks intelligently...

  • Jan 23

    Most in demand programming languages for 2019

    In this article, we have mentioned the analyzed results of the most in demand programming language for 2019...

  • Jan 15

    Web Robots

    Web robots is an internet robot or simply crawlers, or spiders and do not relate this with hardware robots...

  • Jan 12

    Most in demand NoSQL databases software for 2019

    In this article, we have mentioned the analyzed result of most in demand NoSQL database softwares for 2019...

  • Jan 10

    Kotlin : Android App Development Choice

    Kotlin is a general-purpose open-source programming language. It runs on the JVM and its syntax is much like Java...

Follow us

  • etutorialspoint facebook
  • etutorialspoint twitter
  • etutorialspoint linkedin
etutorialspoint youtube
About Us      Contact Us


  • eTutorialsPoint©Copyright 2016-2021. All Rights Reserved.