Forums > Jitter

White Balance?

November 20, 2006 | 1:22 pm

Hi there,

I am currently working on a project where I am using Jitter for colour-tracking. I have 4 different colour balls which are being tracked with jit.findbounds. Whenever I set up the system, I have to spend a while configuring the different colours (depending on the light of the room) so that Jitter knows which colours to track. Does anyone know a way to create a white balance, so that I simply have to show the camera a white object, and it’ll work out what colours is should be looking for?

Thanks,

Ed


November 20, 2006 | 6:35 pm

hello,

below is one quick&dirty way to do something similar.

best,
nesa

#P toggle 400 38 15 0;
#P window setfont Geneva 9.;
#P flonum 569 282 35 9 0 0 0 152 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 428 155 39 9961481 t l l;
#P newex 595 192 46 9961481 zl slice 1;
#P newex 631 214 58 9961481 minimum 0.;
#N vpatcher 513 361 813 593;
#P outlet 260 168 15 0;
#P window setfont Geneva 9.;
#P message 65 91 177 9961481 framerect 140 100 180 140 0 255 0;
#P newex 50 55 40 9961481 t b b l;
#P newex 50 130 106 9961481 jit.lcd 4 char 320 240;
#P inlet 50 30 15 0;
#P outlet 50 163 15 0;
#P connect 1 0 3 0;
#P fasten 4 0 2 0 70 118 55 118;
#P connect 3 0 2 0;
#P fasten 3 2 2 0 85 125 55 125;
#P connect 2 0 0 0;
#P connect 3 1 4 0;
#P fasten 1 0 5 0 55 49 265 49;
#P pop;
#P newobj 27 136 39 9961481 p draw;
#P message 146 34 30 9961481 close;
#P user gswitch2 27 63 39 32 0 0;
#P window setfont "Sans Serif" 9.;
#P newex 117 104 83 9109513 jit.qt.grab 320 240;
#P newex 27 105 85 9109513 jit.dx.grab 320 240;
#P window setfont Geneva 9.;
#P flonum 527 282 35 9 0 0 0 152 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 481 282 35 9 0 0 0 152 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 472 253 40 9961481 !/ 255.;
#P newex 516 253 40 9961481 !/ 255.;
#P newex 560 253 40 9961481 !/ 255.;
#P message 383 360 145 9961481 rscale $1 , gscale $2 , bscale $3;
#P newex 400 72 27 9961481 gate;
#P newex 472 312 98 9961481 pack 1. 1. 1.;
#P user jit.pwindow 26 415 322 242 0 1 0 0 1 0;
#P newex 369 384 59 9961481 jit.scalebias;
#P newex 428 192 143 9961481 unpack 0. 0. 0. 0.;
#P user jit.pwindow 475 128 42 42 0 1 0 0 1 0;
#P newex 400 97 201 9961481 jit.submatrix @dim 40 40 @offset 140 100;
#P user jit.pwindow 26 166 322 242 0 1 0 0 1 0;
#P message 115 34 28 9961481 open;
#P toggle 56 12 15 0;
#P newex 56 33 53 9961481 qmetro 5;
#P newex 400 132 53 9961481 jit.3m;
#P comment 417 39 198 9961481 turn gate on to calculate scaling values;
#P connect 21 0 19 0;
#P fasten 20 0 23 0 122 129 32 129;
#P connect 19 0 23 0;
#P connect 23 0 5 0;
#P fasten 9 0 10 0 374 411 32 411;
#P connect 3 0 2 0;
#P fasten 22 0 21 1 151 55 61 55;
#P fasten 4 0 21 1 120 55 61 55;
#P connect 2 0 21 1;
#P connect 21 1 20 0;
#P fasten 23 1 9 0 61 159 374 159;
#P fasten 13 0 9 0 388 379 374 379;
#P fasten 11 0 13 0 477 352 388 352;
#P connect 28 0 12 0;
#P connect 12 0 6 0;
#P connect 6 0 1 0;
#P fasten 23 1 12 1 61 159 345 159 345 64 422 64;
#P connect 1 2 26 0;
#P connect 26 0 8 0;
#P connect 8 1 16 0;
#P connect 16 0 11 0;
#P fasten 6 0 7 0 405 123 481 123;
#P fasten 16 0 17 0 477 276 486 276;
#P fasten 24 0 16 1 636 241 507 241;
#P lcolor 8;
#P connect 8 2 15 0;
#P connect 15 0 11 1;
#P fasten 15 0 18 0 521 276 532 276;
#P fasten 24 0 15 1 636 245 551 245;
#P lcolor 8;
#P connect 8 3 14 0;
#P connect 14 0 11 2;
#P fasten 14 0 27 0 565 276 574 276;
#P fasten 24 0 14 1 636 249 595 249;
#P lcolor 8;
#P fasten 26 1 25 0 462 182 600 182;
#P connect 25 1 24 0;
#P window clipboard copycount 29;


November 23, 2006 | 11:13 pm

Thanks ever so much for the patch Nesa! (sorry about the delay in replying, I’ve had problems with my internet). I have to confess that I don’t understand what this patch is doing at all!! I’ve been doing quite a lot of head-scratching trying to work it out. If you don’t mind, could you give me an idea of what is happening conceptually in the patch? I’m sorry for my ignorance, I’m very new to Jitter to be honest.

Thanks again for your help,

Ed


November 24, 2006 | 4:50 pm

Hello,

Sorry for not explaining it back then, I was in a bit of hurry…

This patch assumes that pure white on computer screens should be presented
as red, green and blue channels at maximum: 255 in this case.
So, if you are grabbing an pure white pixel, you should get rgb values of
255 255 255, but if the image is a bit greenish, you would get something
like r200 g255 b207 (only green at maximum), or bluish: r203 g201 b255, etc.
So to make that pixel white, you can scale non-maximum channels so that they
are at maximum(greenish example: r128, g255,b128 means that you have to
multiply red and blue by two to reach 255…or you could divide green by
two).
So, the patch first grabs the image, takes a slice of it at the
center(jit.submatrix), then it analyses the image using jit.3m and gets the
current maximum values of red, green and blue channels.
After that it calculates scaling values, and sends them to jit.scalebias
that does the channel scaling on the image.

Step by step tutorial:
1) Adjust graphical gate object depending on your prefered grabing
object(usually dx for xp, qt for osx);
2) Open the graber;
3) Turn qmetro on;

now you should see captured image, with a green square in upper window. this
green rectangle shows what part of matrix will be analysed, so you should
put your white object in front of camera, and make it cover entire green
square;

4) turn the gate on for a moment, to calcuate scaling values(while white
thing is covering green square), and turn it off
you should see the results in lower window afterwards.

hope this helps,
nesa


November 25, 2006 | 2:07 pm

Hi Ed,

I see you’re based in Leicester, so am i, so i’ve dropped you an email to see if you want to meet up and possibly form a local patching circle?

John


November 26, 2006 | 8:01 pm

Thanks so much for the explanation Nesa (as well as the patch!), that’s really helpful!

ED


Viewing 6 posts - 1 through 6 (of 6 total)