Jump to content
  • Advertisement
Sign in to follow this  
Tipotas688

Bilateral Filtering

This topic is 2774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!