# Understanding the Parameters of the Bilateral Filter

Allow me to show you a snip from Szeliski's Computer Vision book on bilateral filter. I don't know how to interpret these kernel definitions: In the actual summation what values do the $k$ and $l$ take? E.g For a kernel of size 5x5 does $k$ take values between negative and positive inf? or between 1 to 5 (e.g. in matlab programming)? Or does it take values from -2 to 2?

Also what do those double bars mean in the definition of range kernel?

• using bilateral filter implimentaion, the iteration results showing better results comparing with other methods, but i dint understand how to chnage the parameters in general equation. – user18487 Nov 27 '15 at 0:30

A small discussion of the details you've asked for:

1. The bilateral ﬁlter is controlled by two parameters: $\sigma$d and $\sigma$r.

• As the range parameter $\sigma$r increases, the bilateral ﬁlter becomes closer to Gaussian blur because the range Gaussian is ﬂatter i.e., almost a constant over the intensity interval covered by the image.

• Increasing the spatial parameter $\sigma$d smooths larger features.

An important characteristic of bilateral ﬁltering is that the weights are multiplied, which implies that as soon as one of the weight is close to 0, no smoothing occurs. As an example, a large spatial Gaussian coupled with narrow range Gaussian achieves a limited smoothing although the ﬁlter has large spatial extent. The range weight enforces a strict preservation of the contours.

"The Norm or the double bars indicate the gaussian distance in the equation.This distance is deﬁned by Gσ(||p − q||), where σ is a parameter deﬁning the extension of the neighborhood."

Since (i,j) and (k,l) are simply spatial points on an image, they will vary from the start of the image to the end of the image. Typically this would be dependent on your indexing measure, for example in a matrix, you've have to range from 0 to 5 for a 5x5 image. The actual values of k,l matter little. Its the relative value which matters far more.

Typically in image processing, a filter kernel is centered upon the destination pixel, so in your example, $k$ and $l$ would take on the values $-2, 1, 0, 1, 2$.

The double-vertical-bar symbol is typically used to denote some kind of norm. In your case, since (I'm assuming) $f(i,j)$ and $f(k,l)$ are scalar values, I'm assuming $\lVert f(i,j) - f(k,l) \rVert^2$ refers to the squared magnitude of the difference between the two pixel values.

• thanks. these are color images. so f(i,j)-f(k,l) is a vector. – cannot image process Dec 17 '12 at 16:44
• I have been reading about bilateral filters and have been confused about the implementation. I asked a question here dsp.stackexchange.com/questions/61988/… . It will be very helpful if you could share your understanding of the bilateral filter. – Suhail Gupta Nov 17 '19 at 11:13