Bilateral filter
Last updated
Last updated
We previously described how the Median filter is poor at performance and bilateral filter is a good supplement to it, to understand why we must look at how the filter works.
The bilateral function takes in a sigma
this describes the intensity of the smoothing similar to and the kernel size. We then loop through each pixel, and we will subtract each of its neighbours with the current pixel, we will multiply this with a "weight" and set the current pixel to the mean of the value. That is a bit convoluted (ha!) but let's see the implementation.
The Bilateral filter is implemented at
It's pretty apparent what we are doing here. Let's check the actual bilateral computation
So let's break down what's going on here
We loop through the neighbours of the centerValue
We then extract the difference of centre value and the current neighbour
From the difference we extract a rangeWeight
this will define how "sharp" our smoothing is
totalWeightedSum
is the sum of product of weight and current neighbour
totalSum
is just the sum of the weights
We divide the above values and return it. This division is done to "normalise" the image so that it maintains the initial brightness or photometric symmetry, a fancier way to say that an image shares properties with its previous state.
From this we achieve the following result
The performance of this algorithm is a lot better than the one previously discussed.