Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualYours3!f

Posted 16 September 2012 - 02:01 PM

Hi,

I'm trying to implement a bilateral gaussian blur. I've already implemented a simple gaussian blur (see below), but I don't know how to turn that into a bilateral one. I've read about bilateral filtering, and I know that this way the weights not only depend on the distance between the samples but between the color intensities as well. Despite this I still have no clue how to do this.

I've used this tutorial to implement the gaussian blur: http://rastergrid.co...inear-sampling/

#version 420 core
uniform sampler2D texture0; //color buffer
uniform vec2 direction; //vec2(1, 0) --> horizontal, vec2(0, 1) --> vertical

in cross_shader_data
{
  vec2 tex_coord;
} i;

out vec4 color;

void main()
{
  float weights[5] =
  {
	0.0702702703, 0.3162162162, 0.2270270270, 0.3162162162, 0.0702702703
  };

  float offsets[5] =
  {
	-3.2307692308, -1.3846153846, 0.0, 1.3846153846, 3.2307692308
  };

  vec2 tex_size = textureSize(texture0, 0);
  vec2 dir = direction / tex_size;

  vec3 result = vec3(0.0);

  for(int c = 0; c < 5; c++)
  {
	result += texture(texture0, i.tex_coord + offsets[c] * dir).xyz * weights[c];
  }

  color = vec4(result, 1.0);
}

so my question is how do I make this blur bilateral?

best regards,
Yours3!f

#3Yours3!f

Posted 16 September 2012 - 02:00 PM

Hi,

I'm trying to implement a bilateral gaussian blur. I've already implemented a simple gaussian blur (see below), but I don't know how to turn that into a bilateral one. I've read about bilateral filtering, and I know that this way the weights not only depend on the distance between the samples but between the color intensities as well. Despite this I still have no clue how to do this.

I've used this tutorial to implement the gaussian blur: http://rastergrid.co...inear-sampling/

#version 420 core
uniform sampler2D texture0; //color buffer
uniform vec2 direction; //vec2(1, 0) --> horizontal, vec2(0, 1) --> vertical

in cross_shader_data
{
  vec2 tex_coord;
} i;

out vec4 color;

void main()
{
  float weights[5] =
  {
	0.0702702703, 0.3162162162, 0.2270270270, 0.3162162162, 0.0702702703
  };

  float offsets[5] =
  {
	-3.2307692308, -1.3846153846, 0.0, 1.3846153846, 3.2307692308
  };

  vec2 tex_size = textureSize(texture0, 0);
  vec2 dir = direction / tex_size;

  vec3 result = vec3(0.0);

  for(int c = 0; c < 5; c++)
  {
	result += (texture(texture0, i.tex_coord + offsets[c] * dir).xyz * 2.0 - 1.0) * weights[c];
  }

  color = vec4(result, 1.0);
}

so my question is how do I make this blur bilateral?

best regards,
Yours3!f

#2Yours3!f

Posted 16 September 2012 - 01:59 PM

Hi,

I'm trying to implement a bilateral gaussian blur. I've already implemented a simple gaussian blur (see below), but I don't know how to turn that into a bilateral one. I've read about bilateral filtering, and I know that this way the weights not only depend on the distance between the samples but between the color intensities as well. Despite this I still have no clue how to do this.

I've used this tutorial to implement the gaussian blur: http://rastergrid.co...inear-sampling/

#version 420 core
uniform sampler2D texture0; //color buffer
uniform vec2 direction;

in cross_shader_data
{
  vec2 tex_coord;
} i;

out vec4 color;
void main()
{
  float weights[5] =
  {
	0.0702702703, 0.3162162162, 0.2270270270, 0.3162162162, 0.0702702703
  };

  float offsets[5] =
  {
	-3.2307692308, -1.3846153846, 0.0, 1.3846153846, 3.2307692308
  };

  vec2 tex_size = textureSize(texture0, 0);
  vec2 dir = direction / tex_size;

  vec3 result = vec3(0.0);

  for(int c = 0; c < 5; c++)
  {
	result += (texture(texture0, i.tex_coord + offsets[c] * dir).xyz * 2.0 - 1.0) * weights[c];
  }

  color = vec4(result, 1.0);
}

so my question is how do I make this blur bilateral?

best regards,
Yours3!f

#1Yours3!f

Posted 16 September 2012 - 01:58 PM

Hi,

I'm trying to implement a bilateral gaussian blur. I've already implemented a simple gaussian blur (see below), but I don't know how to turn that into a bilateral one. I've read about bilateral filtering, and I know that this way the weights not only depend on the distance between the samples but between the color intensities as well. Despite this I still have no clue how to do this.

I've used this tutorial to implement the gaussian blur: http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/

#version 420 core
uniform sampler2D texture0; //color buffer
uniform vec2 direction;

in cross_shader_data
{
  vec2 tex_coord;
} i;

out vec4 color;
void main()
{
  float weights[5] =
  {
    0.0702702703, 0.3162162162, 0.2270270270, 0.3162162162, 0.0702702703
  };
 
  float offsets[5] =
  {
    -3.2307692308, -1.3846153846, 0.0, 1.3846153846, 3.2307692308
  };
 
  vec2 tex_size = textureSize(texture0, 0);
  vec2 dir = direction / tex_size;
 
  vec3 result = vec3(0.0);
 
  for(int c = 0; c < 5; c++)
  {
    result += (texture(texture0, i.tex_coord + offsets[c] * dir).xyz * 2.0 - 1.0) * weights[c];
  }

  color = vec4(result, 1.0);
}

best regards,
Yours3!f

PARTNERS