Re: pick a color from picture, to recover this color coordinates in an other picture


Forums > Jitter > pick a color from picture, to recover this color coordinates in an other picture
April 3, 2012 | 3:47 pm

Hi,
I’ve made my little really simple shader for this problem. hm "==" does the trick…
I would like to know how could I streched the color bar. I trie to put an offset on result.y but I think I must confused .r and .x coordinates in shaders wich I’m not familiar to.
Could you just take a glance to this little patch and shader ? I use the same "scale.png" file than precedently post.
here’s the patch and the shader:

find any common colors in 2 matrixes.

//sampler

uniform sampler2DRect tex0;

uniform sampler2DRect tex1;
uniform vec4 tolerance;

const vec4 one = vec4(1.0);
// texcoord
varying vec2 texcoord0;
varying vec2 texcoord1;

void main()
{

vec4 source = texture2DRect(tex0, texcoord0);
vec4 target = texture2DRect(tex1, texcoord0);
vec4 delta = vec4(source==target);
vec4 result= vec4(delta.x, delta.y + tolerance); //how could I stetch the color bar ?
gl_FragColor = result*source;
}
]]>

– Pasted Max Patch, click to expand. –

[attachment=190098,3640]