For example another method can be - If pixel's color is near target color (within error bounds) - draw pixel in first color, otherwise - draw it in second. This conversion rule is implemented in following GLSL pixel shader code:
uniform sampler2D tex;
bool nearColor(in vec4 col, in vec4 tcol, in float error) {
return abs(col.r-tcol.r) < error &&
abs(col.g-tcol.g) < error &&
abs(col.b-tcol.b) < error ;
}
void main()
{
vec4 xcol = texture2D(tex, gl_TexCoord[0].xy);
vec4 scol = vec4(0.737,0.506,0.404,1.0);
if (nearColor(xcol,scol,0.085))
gl_FragColor = scol;
else
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
}
Image
converted to binary mode:
No comments:
Post a Comment
Comment will be posted after comment moderation.
Thank you for your appreciation.