Forums > Jitter

repeat statements? (pixel by pixel matrix operations)

April 23, 2007 | 9:50 pm

I want to run a live video through a patch I have, but my patch deals with one pixel of the video’s matrix at a time. I know how to unpack the matrix and read the coordinates of a pixel, change it, and repack it into the movie, but I’d like to run this patch through every pixel of the 320×240 video (for each color channel). How can i make a sort of repeat phrase that will stall other processes until it finishes the frame?

Or is there another method of doing it? Thanks for your help.


April 23, 2007 | 9:57 pm

Hi Randy,
Sounds like there is probably a much more efficient way to do what you
are doing using Jitter MOPs, but we can’t tell you what that would be
until you post a simple example patch that shows what you are trying to
accomplish.

Cheers,
Andrew B.


April 23, 2007 | 10:03 pm

I don’t think so, or at least I couldn’t find one. It just does an operation like jit.op with a control matrix and then only applies it if it comes out to be within a certain range. For example if it subtracts one from the other and they’re only 5 units difference in redness, it will just use the original red (otherwise it might make it black). I just want that level of control.


April 23, 2007 | 10:09 pm

Once again, a patch will probably be the best way for us to see what you
are talking about. Without that, language can be a very vague thing.

AB


April 23, 2007 | 10:16 pm

max v2;
#N vpatcher 778 133 1378 533;
#P outlet 225 293 15 0;
#P inlet 242 84 15 0;
#P inlet 307 84 15 0;
#P inlet 200 84 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 225 182 23 196617 abs;
#P number 242 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 307 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 225 205 174 196617 if $i1 < $i2 then set $i3 else set $i4;
#P number 200 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 225 161 27 196617 -;
#P comment 203 123 100 196617 incoming calibrated;
#P comment 306 122 100 196617 tolerance;
#P connect 8 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 7 0;
#P connect 7 0 4 0;
#P connect 4 0 11 0;
#P connect 10 0 6 0;
#P connect 6 0 2 1;
#P connect 5 0 4 1;
#P connect 9 0 5 0;
#P connect 6 0 4 2;
#P connect 3 0 4 3;
#P pop;


April 23, 2007 | 10:20 pm

sounds like you want to use uzi and getcell, but yeah, a patch speaks
10^6 words (or uh, something)

On Apr 23, 2007, at 6:09 PM, andrew benson wrote:

> Once again, a patch will probably be the best way for us to see
> what you
> are talking about. Without that, language can be a very vague thing.
>
> AB

v a d e //

http://www.vade.info
abstrakt.vade.info


April 23, 2007 | 10:31 pm

Well that is the main idea that I posted. if you want to see it in more context—

max v2;
#N vpatcher 283 94 1272 815;
#P origin 18 17;
#P window setfont "Sans Serif" 9.;
#P number 704 151 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 704 127 85 196617 pixeltransparent;
#P number 741 106 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 778 106 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 596 97 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 704 106 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 528 78 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 490 79 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 636 96 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 507 33 112 196617 unpack 0 0 0 0 0 0 0 0;
#P number 279 125 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 242 125 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 243 144 30 196617 pack;
#P newex 243 164 78 196617 prepend getcell;
#P newex 607 305 32 196617 print;
#P message 65 239 33 196617 start;
#P message 25 278 29 196617 stop;
#P number 26 239 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 25 258 52 196617 frame $1;
#P message 227 294 44 196617 settings;
#P user jit.pwindow 553 345 322 242 0 1 0 0 1 0;
#P user ubumenu 400 587 60 196617 0 1 1 0;
#X add pass;
#X add *;
#X add /;
#X add +;
#X add -;
#X add +m;
#X add -m;
#X add %;
#X add min;
#X add max;
#X add abs;
#X add avg;
#X add absdiff;
#X add wrap;
#X add fold;
#X add !pass;
#X add !/;
#X add !-;
#X add !%;
#X add &;
#X add |;
#X add ^;
#X add ~;
#X add >>;
#X add < <;
#X add &&;
#X add ||;
#X add !;
#X add >;
#X add < ;
#X add >=;
#X add < =;
#X add ==;
#X add !=;
#X add >p;
#X add

#X add >=p;
#X add < =p;
#X add ==p;
#X add !=p;
#X add sin;
#X add cos;
#X add tan;
#X add asin;
#X add acos;
#X add atan;
#X add atan2;
#X add sinh;
#X add cosh;
#X add tanh;
#X add asinh;
#X add acosh;
#X add atanh;
#X add exp;
#X add exp2;
#X add ln;
#X add log2;
#X add log10;
#X add hypot;
#X add pow;
#X add sqrt;
#X add ceil;
#X add floor;
#X add round;
#X add trunc;
#X add ignore;
#X prefix_set 0 0 0;
#P message 570 614 32 196617 getop;
#N vpatcher 564 112 981 323;
#P window setfont "Sans Serif" 9.;
#P newex 60 106 55 196617 prepend op;
#P user ubumenu 227 61 60 196617 0 1 1 0;
#X add pass;
#X add *;
#X add /;
#X add +;
#X add -;
#X add +m;
#X add -m;
#X add %;
#X add min;
#X add max;
#X add abs;
#X add avg;
#X add absdiff;
#X add !pass;
#X add !/;
#X add !-;
#X add !%;
#X add &;
#X add |;
#X add ^;
#X add ~;
#X add >>;
#X add < <;
#X add &&;
#X add ||;
#X add !;
#X add >;
#X add < ;
#X add >=;
#X add < =;
#X add ==;
#X add !=;
#X add >p;
#X add

#X add >=p;
#X add < =p;
#X add ==p;
#X add !=p;
#X add sin;
#X add cos;
#X add tan;
#X add asin;
#X add acos;
#X add atan;
#X add atan2;
#X add sinh;
#X add cosh;
#X add tanh;
#X add asinh;
#X add acosh;
#X add atanh;
#X add exp;
#X add exp2;
#X add ln;
#X add log2;
#X add log10;
#X add hypot;
#X add pow;
#X add sqrt;
#X add ceil;
#X add floor;
#X add round;
#X add trunc;
#X add ignore;
#X prefix_set 0 0 0;
#P user ubumenu 163 61 60 196617 0 1 1 0;
#X add pass;
#X add *;
#X add /;
#X add +;
#X add -;
#X add +m;
#X add -m;
#X add %;
#X add min;
#X add max;
#X add abs;
#X add avg;
#X add absdiff;
#X add !pass;
#X add !/;
#X add !-;
#X add !%;
#X add &;
#X add |;
#X add ^;
#X add ~;
#X add >>;
#X add < <;
#X add &&;
#X add ||;
#X add !;
#X add >;
#X add < ;
#X add >=;
#X add < =;
#X add ==;
#X add !=;
#X add >p;
#X add

#X add >=p;
#X add < =p;
#X add ==p;
#X add !=p;
#X add sin;
#X add cos;
#X add tan;
#X add asin;
#X add acos;
#X add atan;
#X add atan2;
#X add sinh;
#X add cosh;
#X add tanh;
#X add asinh;
#X add acosh;
#X add atanh;
#X add exp;
#X add exp2;
#X add ln;
#X add log2;
#X add log10;
#X add hypot;
#X add pow;
#X add sqrt;
#X add ceil;
#X add floor;
#X add round;
#X add trunc;
#X add ignore;
#X prefix_set 0 0 0;
#P outlet 60 126 15 0;
#P user ubumenu 99 61 60 196617 0 1 1 0;
#X add pass;
#X add *;
#X add /;
#X add +;
#X add -;
#X add +m;
#X add -m;
#X add %;
#X add min;
#X add max;
#X add abs;
#X add avg;
#X add absdiff;
#X add !pass;
#X add !/;
#X add !-;
#X add !%;
#X add &;
#X add |;
#X add ^;
#X add ~;
#X add >>;
#X add < <;
#X add &&;
#X add ||;
#X add !;
#X add >;
#X add < ;
#X add >=;
#X add < =;
#X add ==;
#X add !=;
#X add >p;
#X add

#X add >=p;
#X add < =p;
#X add ==p;
#X add !=p;
#X add sin;
#X add cos;
#X add tan;
#X add asin;
#X add acos;
#X add atan;
#X add atan2;
#X add sinh;
#X add cosh;
#X add tanh;
#X add asinh;
#X add acosh;
#X add atanh;
#X add exp;
#X add exp2;
#X add ln;
#X add log2;
#X add log10;
#X add hypot;
#X add pow;
#X add sqrt;
#X add ceil;
#X add floor;
#X add round;
#X add trunc;
#X add ignore;
#X prefix_set 0 0 0;
#P user ubumenu 35 61 60 196617 0 1 1 0;
#X add pass;
#X add *;
#X add /;
#X add +;
#X add -;
#X add +m;
#X add -m;
#X add %;
#X add min;
#X add max;
#X add abs;
#X add avg;
#X add absdiff;
#X add !pass;
#X add !/;
#X add !-;
#X add !%;
#X add &;
#X add |;
#X add ^;
#X add ~;
#X add >>;
#X add < <;
#X add &&;
#X add ||;
#X add !;
#X add >;
#X add < ;
#X add >=;
#X add < =;
#X add ==;
#X add !=;
#X add >p;
#X add

#X add >=p;
#X add < =p;
#X add ==p;
#X add !=p;
#X add sin;
#X add cos;
#X add tan;
#X add asin;
#X add acos;
#X add atan;
#X add atan2;
#X add sinh;
#X add cosh;
#X add tanh;
#X add asinh;
#X add acosh;
#X add atanh;
#X add exp;
#X add exp2;
#X add ln;
#X add log2;
#X add log10;
#X add hypot;
#X add pow;
#X add sqrt;
#X add ceil;
#X add floor;
#X add round;
#X add trunc;
#X add ignore;
#X prefix_set 0 0 0;
#P newex 60 85 202 196617 pak * * * *;
#P connect 1 1 0 0;
#P connect 0 0 6 0;
#P connect 6 0 3 0;
#P connect 2 1 0 1;
#P connect 4 1 0 2;
#P connect 5 1 0 3;
#P pop;
#P newobj 506 612 55 196617 p multi_op;
#P number 169 611 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 206 611 49 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 425 612 72 196617 prepend op;
#P newex 59 645 105 196617 jit.op @op * @val 0.5;
#B color 5;
#P comment 169 645 100 196617 can use a scalar , too;
#P newex 428 238 40 196617 keyup;
#P newex 381 261 52 196617 select 32;
#P newex 381 237 40 196617 key;
#P toggle 381 283 15 0;
#P user jit.pwindow 379 344 162 122 0 1 0 0 1 0;
#P newex 381 303 29 196617 gate;
#P newex 381 324 129 196617 jit.matrix 4 char 320 240;
#P user jit.pwindow 18 340 322 242 0 1 0 0 1 0;
#P toggle 117 229 15 0;
#P user gswitch2 87 271 39 32 1 0;
#P newex 116 247 52 196617 metro 33;
#P message 149 294 28 196617 open;
#B color 9;
#P message 190 294 31 196617 close;
#B color 9;
#P newex 149 314 56 196617 jit.qt.grab;
#P message 24 295 30 196617 read;
#P newex 23 315 105 196617 jit.qt.movie 320 240;
#P comment 693 91 138 196617 incoming calibrated tolerance;
#P connect 3 0 9 0;
#P connect 1 0 9 0;
#P connect 30 0 1 0;
#P connect 27 0 1 0;
#P connect 29 0 1 0;
#P connect 7 0 1 0;
#P connect 2 0 1 0;
#P connect 28 0 27 0;
#P connect 9 0 18 0;
#P fasten 23 0 18 0 575 637 64 637;
#P fasten 22 0 18 0 511 637 64 637;
#P fasten 19 0 18 0 430 637 64 637;
#P connect 8 0 6 0;
#P connect 6 0 7 1;
#P connect 26 0 3 0;
#P connect 7 1 3 0;
#P connect 5 0 3 0;
#P connect 4 0 3 0;
#P connect 12 0 18 1;
#P fasten 21 0 18 1 174 632 159 632;
#P fasten 20 0 18 1 211 632 159 632;
#P connect 34 0 33 0;
#P connect 33 0 32 0;
#P connect 35 0 33 1;
#P connect 10 0 12 0;
#P connect 16 0 15 0;
#P connect 14 0 15 0;
#P connect 15 0 13 0;
#P connect 13 0 11 0;
#P connect 6 0 10 0;
#P connect 32 0 10 0;
#P connect 11 0 10 0;
#P fasten 3 0 11 1 154 337 311 337 311 269 405 269;
#P fasten 1 0 11 1 28 336 277 336 277 271 405 271;
#P connect 24 1 19 0;
#P connect 36 1 38 0;
#P connect 10 1 36 0;
#P connect 36 2 39 0;
#P fasten 18 0 25 0 64 669 542 669 542 332 559 332;
#P connect 36 5 41 0;
#P connect 10 1 31 0;
#P connect 36 6 37 0;
#P connect 36 7 40 0;
#P connect 40 0 44 0;
#P connect 44 0 45 0;
#P connect 43 0 44 1;
#P connect 42 0 44 2;
#P pop;


April 23, 2007 | 10:34 pm

Something like this would probably work:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 241 216 64 196617 jit.op @op ~;
#P outlet 32 288 15 0;
#P newex 32 265 164 196617 jit.op @op +;
#P newex 32 237 65 196617 jit.op @op *;
#P inlet 166 60 15 0;
#P inlet 87 59 15 0;
#P number 140 147 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 87 172 63 196617 jit.op @op < ;
#P newex 87 111 89 196617 jit.op @op absdiff;
#P comment 178 148 53 196617 tolerance;
#P newex 186 239 65 196617 jit.op @op *;
#P connect 3 0 7 1;
#P fasten 3 0 10 0 92 205 246 205;
#P connect 10 0 0 1;
#P connect 0 0 8 1;
#P fasten 6 0 0 0 171 96 191 96;
#P connect 6 0 2 1;
#P fasten 5 0 7 0 92 96 71 96 71 222 37 222;
#P connect 5 0 2 0;
#P connect 8 0 9 0;
#P connect 7 0 8 0;
#P connect 4 0 3 1;
#P connect 2 0 3 0;
#P window clipboard copycount 11;


April 23, 2007 | 10:35 pm

like this ?
one of many ways to do this and i’m sure there’s better ones..

max v2;
#N vpatcher 415 476 1015 876;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 363 96 52 196617 value2;
#P flonum 362 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 290 96 52 196617 value1;
#P flonum 289 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 92 235 87 196617 jit.op @op +;
#P newex 169 207 65 196617 jit.op @op *;
#P newex 92 206 65 196617 jit.op @op *;
#P newex 169 160 69 196617 jit.op @op >=;
#P comment 213 96 52 196617 tolerance;
#P comment 149 97 52 196617 calibrated;
#P flonum 212 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 92 117 89 196617 jit.op @op absdiff;
#P newex 92 159 63 196617 jit.op @op < ;
#P comment 78 99 44 196617 incoming;
#P window linecount 3;
#P comment 261 239 100 196617 tolerance , value 1 and value2 can all
be matrices…;
#P connect 3 0 2 0;
#P connect 2 0 8 0;
#P connect 8 0 10 0;
#P fasten 4 0 2 1 217 151 150 151;
#P fasten 11 0 8 1 294 196 152 196;
#P fasten 3 0 7 0 97 141 174 141;
#P connect 7 0 9 0;
#P connect 9 0 10 1;
#P fasten 13 0 9 1 367 203 229 203;
#P pop;

On Apr 24, 2007, at 12:16 , randy wrote:

> max v2;
> #N vpatcher 778 133 1378 533;
> #P outlet 225 293 15 0;
> #P inlet 242 84 15 0;
> #P inlet 307 84 15 0;
> #P inlet 200 84 15 0;
> #P window setfont "Sans Serif" 9.;
> #P newex 225 182 23 196617 abs;
> #P number 242 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P number 307 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 225 205 174 196617 if $i1 < $i2 then set $i3 else set $i4;
> #P number 200 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 225 161 27 196617 -;
> #P comment 203 123 100 196617 incoming calibrated;
> #P comment 306 122 100 196617 tolerance;
> #P connect 8 0 3 0;
> #P connect 3 0 2 0;
> #P connect 2 0 7 0;
> #P connect 7 0 4 0;
> #P connect 4 0 11 0;
> #P connect 10 0 6 0;
> #P connect 6 0 2 1;
> #P connect 5 0 4 1;
> #P connect 9 0 5 0;
> #P connect 6 0 4 2;
> #P connect 3 0 4 3;
> #P pop;


April 23, 2007 | 10:47 pm

Maybe I’m explaining this wrong. I realized that I didn’t add in a third matrix that’s needed. The main idea is the patch uses the first matrix’s pixel if it’s different enough from the second, but if it’s too similar then the third matrix’s pixel is used. Sorry about that. I really appreciate the attention you’re giving this!


April 23, 2007 | 11:42 pm

On Apr 23, 2007, at 3:47 PM, randy wrote:

>
> Maybe I’m explaining this wrong. I realized that I didn’t add in a
> third matrix that’s needed. The main idea is the patch uses the
> first matrix’s pixel if it’s different enough from the second, but
> if it’s too similar then the third matrix’s pixel is used. Sorry
> about that. I really appreciate the attention you’re giving this!

I would suggest you think about chroma-keying as a way of doing case
dependent processing. A chroma-key mask is basically an if statement
based on difference (with some optional fuzziness if desired). You
can generate other kinds of masks based on situations other than
chromatic difference, but from your description, this sounds like
exactly what you’re looking for.

For an example of using three matrices, check out jitter-examples/
video/keying/jit.chromakey-3sources.pat . It should get you started
in the right direction. Also look at the jit-diy-chromakey.pat for an
example which breaks down the logic internal to a chroma-keying
object in case you need something subtly different.

Using getcell will be tremendously slow for this sort of thing when
compared with using entire matrix operators. If you absolutely can’t
use matrix operators, I would suggest looking at Java or C based cell
processing, though that clearly requires a more serious technical
investment than using matrix operators or max messages.

-Joshua


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