Great article for getting started quickly. So would something like the code below work for a min filter in a 3x3 neighborhood. I will need to do some homework to see how this gets handled on boundary pixels.
Also, in general is there any specific way to deal with binary images… or is best to just pick a channel to work with and use 0.0 for false, and 1.0 for true and render the pixel to black or white accordingly?
[code]uniform vec4 uInputRes1;
uniform sampler2D sInput1;
vec2 input1Offset(int xOffset, int yOffset)
{
return vec2(gl_TexCoord[0].s + (float(xOffset) * uInputRes1.s), gl_TexCoord[0].t + (float(yOffset) * uInputRes1.t));
}
void main()
{
vec4 colorSum = vec4(0.0);
colorSum = texture2D(sInput1, input1Offset(0, 0));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(-1, -1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(0, -1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(1, -1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(1, 0)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(1, 1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(0, 1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(0, -1)));
colorSum = min(colorSum,texture2D(sInput1, input1Offset(-1, 0)));
gl_FragColor = colorSum;
}[/code]