Forums > Jitter

tracking pixels in a matrix and output as individual numbers or list

March 1, 2008 | 7:00 pm

I have a matrix, where pixels change. Active state is white, inactive is black. I want to output a list of the active pixels, so the coordinates of every pixel. Then I want these pixels to be connected to a pitch. the jit.iter is almost what I want but I only get the last pixel (ok, the rest to, but I can’t put them in a list).
In short, my matrix is connected to jit.iter and that is connected to the unpacks. However, how can I make a decent list of the active pixels that is easy to read?


March 1, 2008 | 9:14 pm

one possible way…

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 92 61 84 196617 setcell 0 0 val 0;
#P user jit.pwindow 140 141 82 62 0 1 0 0 1 0;
#P number 77 224 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 63 206 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 49 188 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 35 170 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 35 142 102 196617 unpack i i i i;
#P button 19 61 15 0;
#P message 35 61 56 196617 setall 255;
#P newex 35 118 43 196617 jit.spill;
#P newex 35 88 122 196617 jit.matrix foo 1 char 2 2;
#P connect 0 0 1 0;
#P fasten 0 0 9 0 40 111 146 111;
#P connect 10 0 0 0;
#P connect 4 3 8 0;
#P connect 4 2 7 0;
#P connect 4 1 6 0;
#P connect 4 0 5 0;
#P connect 1 0 4 0;
#P connect 2 0 0 0;
#P connect 3 0 0 0;
#P window clipboard copycount 11;


March 1, 2008 | 11:27 pm

Almost, but I have 1200 pixels to unravel (a matrix of 40X30) and the unpack doesnt take that much outlets. What should I do?


March 1, 2008 | 11:36 pm

What are you trying to do with this list. I would strongly advise
against using lists. You should keep everything in the matrix domain
if possible. If you’re going to audio, you could use jit.buffer~,
jit.peek~ etc.

wes

On Sat, Mar 1, 2008 at 3:27 PM, Samuel Van Ransbeeck

wrote:
>
> Almost, but I have 1200 pixels to unravel (a matrix of 40X30) and the unpack doesnt take that much outlets. What should I do?
>
>
>


March 1, 2008 | 11:42 pm

entirely depends on what you’re trying to do.
if you need to keep the cell coord info, i would use jit.iter, otherwise, you can stick a normal iter after the jit.spill.
each cell value comes through, sel 255 will send a bang if it’s "active" and you can send that bang wherever you want.

or if you need to process the whole list in some way, look at the zl object or the listops objects.

if you just want to see the state of your matrix, hook it up to a jit.cellblock, couldn’t be easier.

-rob


March 1, 2008 | 11:52 pm


March 2, 2008 | 3:01 am

> Then I want these pixels to be connected to a pitch

what do you mean by "connected to a pitch"?

here’s another way (when there are dozens)
-a coll to store
-jit.3m middle outlet to find the percentage.

next time you should start by posting a patch because your request is
really not clear… nobody here has the slightest idea about what you
finally want to achieve.
my guess is that the rest of your process contains the major problem.

one last advise, try to take it easy on the unpacks.

//yac

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 117 318 84 196617 print percentage;
#P newex 280 341 27 196617 i;
#P newex 280 289 44 196617 sel 255;
#P newex 280 371 80 196617 print on_values;
#P newex 359 294 32 196617 * 40;
#P newex 328 312 27 196617 +;
#P newex 328 273 40 196617 unpack;
#P newex 117 161 106 196617 jit.op @op > @val 0.5;
#P newex 280 248 41 196617 jit.iter;
#P user jit.pwindow 421 223 82 62 0 1 0 0 1 0;
#P newex 117 275 40 196617 / 2.55;
#P newex 117 244 53 196617 jit.3m;
#P button 117 94 15 0;
#P newex 117 125 109 196617 jit.noise 1 char 40 30;
#P connect 3 0 13 0;
#P connect 12 0 10 0;
#P connect 5 0 11 0;
#P connect 11 0 12 0;
#P fasten 8 0 12 1 333 335 302 335;
#P connect 6 0 2 0;
#P connect 6 0 5 0;
#P connect 6 0 4 0;
#P connect 7 0 8 0;
#P connect 9 0 8 1;
#P connect 7 1 9 0;
#P fasten 5 1 7 0 300 269 333 269;
#P connect 0 0 6 0;
#P connect 2 1 3 0;
#P connect 1 0 0 0;
#P window clipboard copycount 14;


March 2, 2008 | 3:07 am

Here goes the conway patch. I want to know which pixel is alive and from every pixel alive i want it to sent a bang (if then …) to a makenoteobject. For that I need to output the coordinates of every pixel and its state. Most important is too know which cells are alive, and this in an automated way. I have written algorhitmic music once withdoing all the calculations and so by hand. I really want to avoid doing that again

max v2;
#N vpatcher 100 100 700 500;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 272 245 104 196617 bgcolor 220 220 192;
#P toggle 12 137 15 0;
#N vpatcher 40 55 444 408;
#P window setfont "Sans Serif" 9.;
#P newex 62 295 40 196617 change;
#P outlet 62 319 15 0;
#P newex 62 273 29 196617 == 0;
#P newex 62 231 110 196617 unpack 0 0 0 0;
#P newex 62 252 110 196617 expr $i1+$i2+$i3+$i4;
#P newex 34 209 53 196617 jit.3m;
#P newex 34 47 27 196617 t l b;
#P newex 34 188 123 196617 jit.op 1 char 40 30 @op -;
#P newex 147 118 70 196617 prepend index;
#N counter 0;
#X flags 0 0;
#P newobj 147 93 66 196617 counter 0 1;
#P newex 225 118 105 196617 prepend outputmatrix;
#N counter 0;
#X flags 0 0;
#P newobj 225 93 66 196617 counter 1 0;
#P newex 147 151 138 196617 jit.matrixset 2 1 char 40 30;
#P inlet 34 27 15 0;
#P connect 0 0 7 0;
#P connect 7 0 6 0;
#P connect 6 0 8 0;
#P connect 8 2 10 0;
#P connect 10 0 9 0;
#P connect 9 0 11 0;
#P connect 11 0 13 0;
#P connect 13 0 12 0;
#P connect 10 1 9 1;
#P connect 10 2 9 2;
#P fasten 7 1 4 0 56 78 152 78;
#P connect 4 0 5 0;
#P fasten 7 0 1 0 39 143 152 143;
#P fasten 3 0 1 0 230 143 152 143;
#P connect 5 0 1 0;
#P connect 1 0 6 1;
#P connect 10 3 9 3;
#P fasten 7 1 2 0 56 78 230 78;
#P connect 2 0 3 0;
#P pop;
#P newobj 12 114 75 196617 p checkfordead;
#P user ubumenu 289 41 103 196617 0 1 1 0;
#X add R-pentomino;
#X add pentadecathlon;
#X add pulsar;
#X prefix_set 0 0 0;
#N vpatcher 30 70 430 370;
#P window setfont "Sans Serif" 9.;
#P newex 54 82 52 196617 t b l clear;
#P newex 64 143 140 196617 sprintf setcell %i %i val 255;
#P newex 64 121 45 196617 zl iter 2;
#P outlet 54 200 15 0;
#P inlet 54 54 15 0;
#P connect 0 0 4 0;
#P connect 4 0 1 0;
#P connect 3 0 1 0;
#P connect 4 2 1 0;
#P connect 4 1 2 0;
#P connect 2 0 3 0;
#P pop;
#P newobj 289 87 35 196617 p putit;
#N coll ;
#T flags 1 0;
#T 0 20 15 21 15 19 16 20 16 20 17;
#T 1 10 15 11 15 12 15 13 15 14 15 15 15 16 15 17 15 18 15 19 15;
#T 2 20 15 19 16 20 16 21 16 19 17 21 17 19 18 20 18 21 18 20 19;
#P newobj 289 63 53 196617 coll;
#P window linecount 6;
#P comment 263 145 123 196617 jit.conway wraps the matrix as a torus (i.e. cells in the game moving off an edge of the matrix re-appear on the opposite side of the matrix).;
#P window linecount 1;
#P comment 9 76 85 196617 ? clear the game.;
#P comment 114 22 85 196617 ? start the game.;
#P comment 85 305 193 196617 works with uniplanar matrices as well.;
#P message 37 91 58 196617 clear , bang;
#N vpatcher 30 70 393 510;
#P window setfont "Sans Serif" 9.;
#P newex 57 100 41 196617 route 1;
#P newex 57 77 42 196617 zl rot 1;
#P outlet 225 369 15 0;
#P inlet 57 12 15 0;
#P newex 57 122 65 196617 vexpr $i1/4;
#P newex 225 325 75 196617 prepend setcell;
#P newex 225 304 63 196617 pack 0 0 s 0;
#P message 292 276 14 196617 0;
#P message 264 276 26 196617 255;
#P newex 264 252 40 196617 sel 0 1;
#P newex 264 230 41 196617 == 255;
#P newex 225 186 51 196617 route cell;
#P newex 57 55 49 196617 zl slice 3;
#P newex 225 206 49 196617 zl slice 3;
#P newex 57 32 63 196617 route mouse;
#P newex 57 164 178 196617 jit.matrix life2 1 char 40 30 @thru 1;
#P newex 57 141 75 196617 prepend getcell;
#P newex 225 346 27 196617 t b l;
#P connect 14 0 3 0;
#P connect 3 0 5 0;
#P connect 5 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 13 0;
#P connect 13 0 1 0;
#P connect 1 0 2 0;
#P fasten 0 1 2 0 247 397 38 397 38 161 62 161;
#P connect 2 1 6 0;
#P connect 6 0 4 0;
#P connect 4 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 0 0;
#P connect 0 0 15 0;
#P connect 4 1 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P fasten 9 0 11 3 269 297 281 297;
#P fasten 10 0 11 3 297 297 281 297;
#P fasten 8 1 10 0 284 272 297 272;
#P pop;
#P newobj 247 274 55 196617 p celldraw;
#P button 69 42 15 0;
#P user jit.pwindow 96 143 162 122 0 1 0 0 1 0;
#P newex 97 114 115 196617 jit.matrix life2 @thru 1;
#P newex 97 67 139 196617 jit.matrix life2 1 char 40 30;
#P toggle 97 21 15 0;
#P newex 97 42 50 196617 metro 50;
#P newex 97 90 55 196617 jit.conway;
#B color 5;
#P window linecount 2;
#P comment 108 269 130 196617 ? draw in the pwindow to add ‘live’ cells.;
#P window linecount 1;
#P comment 289 25 100 196617 ? some patterns.;
#P window linecount 3;
#P comment 11 154 67 196617 dead world (no change or oscillation).;
#P fasten 3 0 19 0 102 110 17 110;
#P connect 19 0 20 0;
#P connect 5 0 4 0;
#P fasten 9 0 6 0 74 62 102 62;
#P connect 4 0 6 0;
#P connect 6 0 3 0;
#P connect 3 0 7 0;
#P fasten 11 0 7 0 42 110 102 110;
#P fasten 10 0 7 0 252 301 89 301 89 110 102 110;
#P fasten 17 0 7 0 294 110 102 110;
#P connect 7 0 8 0;
#P connect 8 1 10 0;
#P connect 18 0 16 0;
#P connect 16 0 17 0;
#P pop;


March 2, 2008 | 3:14 am

anyway, your solution seems to work good enough for now. I will be using this printed list to get my notes. Would it be possible to export the printed text in the max window to an excellsheet or so, then I can look easier which notes are common in every change of generation.


March 2, 2008 | 1:28 pm

the [print] was only there to illustrate.
if you don’t know about the [coll] I strongly recommend you spend some
time reading its help file and especially the read, write & dump
messages.

anyways, I m out of this thread, good luck!

//yac

>
> anyway, your solution seems to work good enough for now. I will be
> using this printed list to get my notes. Would it be possible to
> export the printed text in the max window to an excellsheet or so,
> then I can look easier which notes are common in every change of
> generation.


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