No account yet ?
A bilateral filter is a nonlinear smoothing filter that preserves edges and reduces noise in images.
It replaces the intensity of each pixel with a weighted average of the intensity values of neighboring pixels.
This weight can be based on a Gaussian distribution.
The weights depend not only on the Euclidean distance of the pixels but also on the radiometric differences.
This preserves sharp edges.
Tested in Anaconda and Python 3.7
import cv2 from matplotlib import pyplot as plt # Read the image. img = cv2.imread('pexels-elias-de-carvalho-1375849.jpg') plt.imshow(cv2.cvtColor(img.astype('uint8'), cv2.COLOR_BGR2RGB)) plt.axis('off') plt.title('Originale') plt.show() # Apply bilateral filter with d = 15, # sigmaColor = sigmaSpace = 75. bilateral = cv2.bilateralFilter(img, 20, 125, 125) # Save the output. # cv2.imwrite('frame_bilateral.jpg', bilateral) plt.imshow(cv2.cvtColor(bilateral.astype('uint8'), cv2.COLOR_BGR2RGB)) plt.axis('off') plt.title('Bilateral') plt.show()
Original image
Filtered image - Bilateral
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License