graphics - Anyone know where i can find a glsl implementation of a bilateral filter (blur)? -


i'm looking "selective blur" or "surface blur" on gpu. i've read research papers on subject, , seen deal of c code, ideally i'd in glsl, hsl, or cg.

actually, bilateral blur not different gaussian blur, have multiply value of sample gaussian factor multiplied result of "closeness' function between actual values of centre pixel , sampled pixel.

so, in pseude glsl

vec3 centrecolour = texture2d(image,texcoord); vec3 result = centrecolour; float normalization = 1; (int = 0; < num_samples; ++1) {    vec3 sample = texture2d(image, texcoord + offsets[i]);    float gaussiancoeff = computegaussiancoeff(offsets[i]);     //depends on implementation, quick    float closeness = 1.0f - distance(sample,centrecolour) / length(vec3(1,1,1));     float sampleweight = closeness * gaussian;     result += sample * sampleweight;    noralization += sampleweight; } vec3 bilateral = result / normalization; 

you should have better way determine closeness value, eg in perceptively uniform space such luv.

for optimization, can apply techniques work gaussian blur, apart ones ignore fact have know pixel's value. example, pure gaussian can choose texcoords wisely , integrate 4 pixels in 1 fetch. won't work.

the big things work:

*separate filter. instead of 5x5 samples (25), 5 horizontally, save intermediate buffer, , 5 vertically. won't same, still remove noise.

*perform filter on lower resolution, , composit orignal detail back.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -