Bilateral Filtering

Started by
46 comments, last by Tipotas688 13 years, 5 months ago
Hello, I am trying to write a bilateral filter in HLSL but I haven't found a good explanation, nor algorithmic or mathematical representation of it.

The best thing I've found is:

The intensity value at each pixel in an image is replaced by a weighted average of intensity values from nearby pixels(do I make the kernel? I suppose it exponentially decreases?). Crucially the weights depend not only on Euclidean distance but also on distance in color space from the pixel in question

Well its really not that clean, any tips?
Advertisement
What are you going to use it for? More often than not when people talk about bilateral filters in graphics they're talking about doing it with respect to discontinuities in the depth buffer and/or the normals, rather than in the color.
I just want it for 2D pictures nothing fancy, isn't it called trilateral the one with normals included?
In any case I want it to blur stuff without messing with the edges :P
This presentation goes over bilateral filtering:
http://developer.amd.com/gpu_assets/ShopfMixedResolutionRendering.pdf
something more 2D?
How are you with implementing Gaussian filtering? In gaussian filtering you have something of this nature for each pixel in your kernel:
    weight = exp(-(deltax^2 + deltay^2) / sigma^2)
Well Bilateral filtering is much the same, except you add a term which is the difference with the center pixel of the kernel:
    weight = exp(-(deltax^2 + deltay^2) / sigma^2) * exp(-delta_color^2 / color_sigma^2)
How you choose to measure color difference is your choice (L1 / L2 norms are kind of common).

If you want something even better than bilateral filtering, check out geodesic support weights. I implemented it for my stereo vision research and it gives superior results over adaptive support weights (a bilateral weighting scheme) in most cases.
thats very cool thanks for both!
Hmm I am still a bit confused with the whole kernel business

How big should be the kernel? 3x3? The whole image? My preference? Which center should I use, for example in simple blur i ll use the average of the surrounding pixels in order to calculate the center pixel's value then move to the next one. How do I go about for this one?
anyone?
Quote:Original post by Tipotas688
Hmm I am still a bit confused with the whole kernel business

How big should be the kernel? 3x3? The whole image? My preference?

Your preference:) It depends on the results you want to achieve.

Quote:Original post by Tipotas688Which center should I use, for example in simple blur i ll use the average of the surrounding pixels in order to calculate the center pixel's value then move to the next one. How do I go about for this one?

The same way, only the weights change. They don't depend only on the ralative position in image space but also the relative position in color space (and/or depth ...etc. why not?).

good documentation about bilateral filtering.

This topic is closed to new replies.

Advertisement