
218 III Image Space
//Return the missing chrominance (Co or Cg) of a pixel :
//a1-a4 are the four neighbors of the center pixel a0 .
float filter( vec2 a0 , vec2 a1, vec2 a2 , vec2 a3, vec2 a4)
{
vec4 lum = vec4( a1.x, a2.x , a3.x, a4.x);
vec4 w = 1.0 - step( THRESH, abs(lum - a0.x ));
float W = w.x + w.y + w.z + w.w;
//Handle the special case where all the weights are zero.
W = (W ==0.0)? W : 1.0/ W;
return (w.x*a1.y+w.y*a2.y+w.z*a3.y+w.w*a4.y)*W;
}
Listing 4.2. GLSL implementation of the edge-directed reconstruction filter.
ages, since the luminance is always correct, but they can become more pronounced
when motion is involved.
To eliminate these reconstruction ...