Python OpenCV
About Lesson

In this Python OpenCV lesson we are going to learn about Python OpenCV Bilateral Filtering, this is the fourth technique for image smoothing or blurring in OpenCV. a bilateral filter is non-linear, edge-preserving and noise-reducing smoothing filter. the intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels. This weight can be based on a Gaussian distribution.

 

 

This is the complete code for this lesson.

 

 

 

For this lesson we are going to use this image, and we want to smooth this image using Bilateral method.

OpenCV Filtering
OpenCV Filtering

 

 

 

This is the syntax for Bilateral Filtering.

dst It is the destination or output image
d A variable of the type integer representing the diameter of the pixel neighborhood.
sigmacolor A variable of the type integer representing the filter sigma in the color space.
sigmaspace A variable of the type integer representing the
filter sigma in the coordinate space.

 Also you can use borderType if you want.

 

 

 

 In here we are going to create our Bilateral Filtering.

 

 

 

Because we are going to show our image in Matplotlib, so Matplotlib uses RGB (Red, Green, Blue) color system, and OpenCV uses BGR (Blue, Green, Red) color system, we need to convert the BGR color to RGB. if we don’t do this there will be messed up in the color.

 

 

 

Run the complete code and this is the result.

Python OpenCV Bilateral Filtering
Python OpenCV Bilateral Filtering