Hi all,
Working my way through my d3d11 book, I've got an assignment to redo my working gaussian blur for a bilateral blur.
So I've digged and digged, googled and googled some more and the monkey explanation for me is:
- gaussian blur: predefined static weights for the surrounding pixels
- bilateral blur: weights depend on the difference in pixel colors and the distance the pixels are from the source pixel
(eventually leading to a 1.0 total weights for all neighbouring pixels)
So I started figuring out my existing gaussian blur, and that's clear (pseudo code):
/* float blurWeights[11] =
{
0.05f, 0.05f, 0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.05f, 0.05f,
};
gCache = org. texture pixels
blurRadius = 5
newPixelCol = float4(0, 0, 0, 0);
for i= -blurRadius to blurRadius
{
k = orgPixel.x + 5 + i
newPixelCol += blurWeights[i+blurRadius] * gCache[k];
}
output = newPixelCol;
*/
And drawn out:
So, now how to get from there to the bilateral blur?
I've written things out in Excel to get a good understanding.
I came up with an idea to calculate the weight based in difference in pixel colors of the neighboring pixels, but my conclusion a few minutes ago, is that averaging the R, G and B differences will not work, because the average will always be 0.0f for all neighboring pictures.
And this is were I stopped / came so far...
My question;
- do you have any idea how I can somehow determine the difference in pixels so I can order them to share the weight of 1.0 over my 11 pixels, based on the sorted difference in pixel colors?
What I can think of, is taking the highest difference of one of the 3 components (R,G,B), that way I can sort all 10/11 pixels and lookup the weights in some sort of lookup table (predefined).
The aimed result is keeping the edges better, besides a nice blur (pixels that are 'a like' will be better visible that way)