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

Mar 27, 2012 at 10:22am

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

stupid problem I guess:
I have two pictures for instance.
Thx to suckah, I have rgb coordinates of my mouse cursor.
I would like to find this particular picked color in an other picture.
I trie with jit.findbounds, but the color displayed in the second picture is not as expected. (see the patch).
“jit.op @op==” should be a solution too, (xray.cellocoordinates should give me the coords, but doesn’t work…).
don’t really know what I do wrong…
any help would appreciated.

– Pasted Max Patch, click to expand. –
Mar 27, 2012 at 10:38am

i just had a quick look at your patch, but it seems to me you’re asuming suckah gives you ARGB. in fact it outputs RGBA, so you’re ignoring red and using alpha, so that it finds unexpected colors…

Mar 27, 2012 at 10:48am

thx for response. stupid mistake; change this gives me nobounds at all, worse

I’m not really kind of jit.findbounds anyway…sure there is a better way……
well ok if it could just work;)

– Pasted Max Patch, click to expand. –


Mar 27, 2012 at 11:49am

ok, no i have no idea wth is going on :(

Mar 27, 2012 at 7:36pm

would some of you know about this ? Would it be a bug ?

Mar 27, 2012 at 10:53pm

i think you just gave it too small a color range. i tried with the green number box and it goes better:

– Pasted Max Patch, click to expand. –
Mar 28, 2012 at 3:18am

I still don’t really get the result, why such a great difference according to the picked color…?
When I am in the “red area”, the bound is x boundbox is 320, almost the entire matrix, I need more precision…

Shouldn’t be possible to just retrieve one pixel of the second image ?

What I really need: If I pick white color from the first picture by example, I need to get cellcoords in the second picture of cells wich respond to “yes I’am white and here’s my xy coordinates”.

I’m pretty lost about this ! thx anyway oldturtle.


Mar 28, 2012 at 3:48am

Need specific description,thanks.

Mar 28, 2012 at 3:56am

no time for bycycle right now, if anyone has more wise advice, I’ll take it ;)

Mar 29, 2012 at 7:28am

would someone know about this ?
little emergency here !

Mar 29, 2012 at 9:46am

Noticed your post yesterday and i had a go but i’m also having a hard time trying to solve this. Somehow the colors get compared individually i think. Sure somebody else will chime in.

HTH (a bit)

– Pasted Max Patch, click to expand. –
Mar 29, 2012 at 10:48am

Thx a lot!!
I was little rushed.
really nice little patch comparing to my mess !!
big up

Mar 29, 2012 at 5:13pm

sorry for the noise, but I still have lot of weird values…though I have to be very precise…
unicolor works just fine, the problem is when the color is composed of several primary colors…
I'm really lost…fiou…
I attached the patch and my thermal picture with its scale, wich I have to analyse to know almost every pixel temperature !


– Pasted Max Patch, click to expand. –


  1. thermo.jpeg
Mar 29, 2012 at 6:01pm

what do you want to do with the results?
i would just use jit.chromakey, which will allow you to adjust things like threshold and feathering.

you can tell it to output the keyed channel (@mode 1 or 2).

if you need it to be binary, send it to a jit.op @op > for thresholding.

Mar 29, 2012 at 6:15pm

thx rob.
I have to analyse the argb pixel from a thermal picture, and find the position of the corresponding color in the scale picture to deduce the temperature of the analyse pixel…

I’m gonna try jit.chromakey, but I’m affraid of the needed ressources (about 10 points, so 10 jit.chromakey).

Apr 3, 2012 at 3:47pm

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.


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. –


  1. scale.png

You must be logged in to reply to this topic.