Picture Tiling – help !

Sep 11, 2006 at 8:36pm

Picture Tiling – help !

Hi,
apologies in advance for the ugliness of the patch below – I’m new to jitter ! What I’m trying to do is to nicely tile an indeterminate number (probably between 100 – 200) of jpegs (named 1.jpeg, 2.jpeg etc) into a matrix. The patch below does this by scripting a ‘glue’ with the requisite number of columns / rows and then filling it. However this feels like an unnecessarily slow, clumsy and complicated way of doing it. Does anyone have any better suggestions ??

Thanks,
Richard.

max v2;
#N vpatcher 0 0 1152 788;
#P origin -123 35;
#P window setfont “Sans Serif” 9.;
#P newex 658 363 33 9109513 del 50;
#P button 734 335 15 0;
#P button 817 93 15 0;
#P button 722 375 15 0;
#P newex 648 466 27 9109513 + 1;
#P objectname add1;
#P newex 858 360 45 9109513 loadbang;
#P window linecount 2;
#P message 14 222 144 9109513 script connect syncflag 0 rich 0 ;;
#P message 30 172 130 9109513 script connect add1 0 gate 0 ;;
#P message 38 128 136 9109513 script connect movie 0 gate 1 ;;
#P window linecount 1;
#P message 260 236 80 9109513 script delete gate;
#P message 621 395 16 9109513 -1;
#P message 622 420 64 9109513 syncinlet $1;
#P objectname syncflag;
#P newex 401 38 24 9109513 sqrt;
#P newex 348 210 27 9109513 int;
#P message 353 368 132 9109513 script connect gate $1 rich $1;
#P button 332 265 15 0;
#P newex 357 344 45 9109513 pack 0 0;
#P newex 354 316 27 9109513 – 1;
#P newex 348 291 40 9109513 uzi 48;
#P window linecount 2;
#P comment 408 273 100 9109513 this draws the connections;
#P message 350 234 229 9109513 script new gate newex 650 500 261 9109513 gate $1 ;;
#P window linecount 1;
#P newex 838 388 40 9109513 metro 2;
#P button 176 238 15 0;
#P message 166 263 143 9109513 script connect rich 0 window01 0;
#P user jit.pwindow 124 424 467 286 0 1 0 0 1 0;
#P objectname window01;
#P message 919 144 26 9109513 stop;
#P message 837 193 14 9109513 0;
#P button 831 140 15 0;
#P newex 873 189 50 9109513 metro 250;
#N counter 0 0 100;
#X flags 0 0;
#P newobj 821 236 76 9109513 counter 0 0 100;
#P number 393 76 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 696 39 18 9109513 16;
#P number 743 261 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname counterno;
#P newex 762 317 57 9109513 prepend set;
#P newex 762 295 109 9109513 sprintf read %ld.jpeg.jpg;
#P user jit.pwindow 725 428 82 62 0 1 0 0 1 0;
#P message 765 353 79 9109513 read 16.jpeg.jpg;
#P newex 740 405 91 9109513 jit.qt.movie 600 800;
#P objectname movie;
#P newex 270 46 66 9109513 t b b b b b;
#P newex 255 109 27 9109513 int;
#P newex 220 111 27 9109513 int;
#P button 275 22 15 0;
#P newex 213 137 44 9109513 pack 1 2;
#P message 241 208 77 9109513 script delete rich;
#P window linecount 2;
#P message 213 168 326 9109513 script new rich newex 650 550 313 9109513 jit.glue @rows $1 @columns $2 ;;
#P window linecount 1;
#N thispatcher;
#Q end;
#P newobj 194 324 54 9109513 thispatcher;
#P window linecount 3;
#P comment 721 31 100 9109513 Total number of pictures (needs to be square rootable );
#P window linecount 2;
#P comment 433 63 100 9109513 Appropriate no of columns / rows;
#P window setfont “Sans Serif” 14.;
#P window linecount 4;
#P comment 14 348 311 9109518 This creates and links an appropriately sized glue and gate. The counter then reads in each picture and increments the gate – sending it to the next glue slot.;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 650 550 313 9109513 jit.glue @rows 4 @columns 4;
#P objectname rich;
#P newex 650 500 261 9109513 gate 16;
#P objectname gate;
#P connect 12 0 44 0;
#P connect 12 0 43 0;
#P connect 12 0 42 0;
#P connect 1 0 26 0;
#P connect 28 0 27 0;
#P connect 6 0 28 0;
#P connect 6 0 5 0;
#P connect 44 0 5 0;
#P connect 42 0 5 0;
#P connect 41 0 5 0;
#P connect 36 0 5 0;
#P connect 30 0 5 0;
#P connect 27 0 5 0;
#P connect 7 0 5 0;
#P connect 43 0 5 0;
#P connect 10 0 8 0;
#P connect 8 0 6 0;
#P connect 12 3 10 0;
#P connect 20 0 10 1;
#P connect 12 4 7 0;
#P connect 11 0 8 1;
#P connect 12 3 11 0;
#P connect 12 4 41 0;
#P connect 9 0 12 0;
#P connect 20 0 11 1;
#P connect 19 0 9 0;
#P connect 20 0 9 0;
#P connect 12 1 35 0;
#P connect 12 2 37 0;
#P connect 35 0 32 0;
#P connect 37 0 30 0;
#P connect 34 0 36 0;
#P connect 32 2 33 0;
#P connect 33 0 34 0;
#P connect 19 0 37 1;
#P connect 19 0 32 1;
#P connect 32 2 34 1;
#P connect 38 0 20 0;
#P connect 19 0 38 0;
#P connect 50 0 40 0;
#P connect 40 0 39 0;
#P connect 18 0 46 0;
#P connect 46 0 0 0;
#P connect 39 0 1 0;
#P connect 0 0 1 0;
#P connect 47 0 50 0;
#P connect 0 1 1 1;
#P connect 0 2 1 2;
#P connect 0 3 1 3;
#P connect 14 0 47 0;
#P connect 13 0 15 0;
#P connect 0 4 1 4;
#P connect 17 0 49 0;
#P connect 29 0 13 0;
#P connect 14 0 13 0;
#P connect 21 0 18 0;
#P connect 0 5 1 5;
#P connect 18 0 16 0;
#P connect 16 0 17 0;
#P connect 17 0 14 0;
#P connect 49 0 14 0;
#P connect 0 6 1 6;
#P connect 0 7 1 7;
#P connect 0 8 1 8;
#P connect 19 0 48 0;
#P connect 22 0 21 0;
#P connect 0 9 1 9;
#P connect 19 0 23 0;
#P connect 48 0 23 0;
#P connect 23 0 24 0;
#P connect 45 0 29 0;
#P connect 0 10 1 10;
#P connect 24 0 21 2;
#P connect 0 11 1 11;
#P connect 25 0 22 0;
#P connect 23 0 22 0;
#P connect 19 0 21 4;
#P connect 0 12 1 12;
#P connect 13 0 0 1;
#P connect 0 13 1 13;
#P connect 21 2 25 0;
#P connect 0 14 1 14;
#P connect 0 15 1 15;
#P pop;

#27576
Sep 11, 2006 at 9:59pm

On 9/11/06, Richard wrote:
>
> Hi,
> apologies in advance for the ugliness of the patch below – I’m new to jitter ! What I’m trying to do is to nicely tile an indeterminate number (probably between 100 – 200) of jpegs (named 1.jpeg, 2.jpeg etc) into a matrix. The patch below does this by scripting a ‘glue’ with the requisite number of columns / rows and then filling it. However this feels like an unnecessarily slow, clumsy and complicated way of doing it. Does anyone have any better suggestions ??

Yes. I’m assuming you know the dimensions of your images before hand
and that they’re probably all the same dimension. I would do this
with a javascript. You can JS a movie and do something like this:

var numImages = 200;
var imageDims = [320, 240];
var movie = new JitterObject(“jit.qt.movie”, imageDims);

var matrix = new JitterMatrix(4, “char”, numImages*imageDims[0], imageDims[1]);
matrix.usesrcdim = 1;
matrix.srcdimstart = [0, 0];
matrix.srcdimend = [imagedims[0]-1, imagedims[1]-1];
matrix.usedstdim = 1;

for(var i=0; i < numImages; i++) {
movie.read(i + “.jpg”);
matrix.dstdimstart = [i*imageDims[0], 0];
matrix.dstdimend = [(i+1)*imageDims[0]-1, imagedims[1]-1];
movie.matrixcalc(matrix, matrix);
}

Anyway, something like this should work for you. Keep in mind that I
wrote this code in the email, so it might have some errors, but I
think it gets the idea across. If you want to tile in x and y
dimension use 2 for loops and adjust the dstdimstart and dstdimend
calculations accordingly. I think this will work much much better
than glue and will have the added benefit of being scalable.

wes

#83517
Sep 13, 2006 at 12:49pm

Thanks for this. This looks good but while I think I understand how it’s working I’ve not used JS before and am unsure how to actually implement it ?? I’ve looked through the JS tutorials – should I put this in a function and then call that function ? Can’t seem to get anything to work. Any pointers would be greatly appreciated.

Thanks again,
Richard.

#83518
Sep 13, 2006 at 6:53pm

Another possibility would be to use dstdim and counter to dynamically
change what part of the matrix the frames are written to. The patch
below combines this with a bit of Lobject magic.

Best,
Trond

#P user jit.pwindow 390 71 302 402 0 1 0 0 1 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 97 355 175 196617 dstdimstart $1 $2 , dstdimend $3 $4;
#P newex 97 331 66 196617 Lsub 0 0 1 1;
#P newex 97 306 107 196617 Lmult 75 200 75 200;
#P newex 97 280 66 196617 Ladd 0 0 1 1;
#P newex 97 254 66 196617 pack 0 0 0 0;
#P newex 97 203 27 196617 % 4;
#P newex 151 216 27 196617 / 4;
#P newex 66 391 197 196617 jit.matrix 4 char 300 800 @usedstdim 1;
#P newex 66 147 27 196617 t l b;
#N counter 0 0 15;
#X flags 0 0;
#P newobj 97 174 77 196617 counter 0 0 15;
#P flonum 158 62 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 158 82 42 196617 rate $1;
#P message 218 62 28 196617 read;
#P flonum 119 62 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 66 62 15 0;
#P newex 66 82 63 196617 qmetro 100;
#P newex 66 119 105 196617 jit.qt.movie 150 200;
#B color 5;
#P connect 10 0 12 1;
#P connect 10 0 12 3;
#P connect 7 0 11 0;
#P fasten 7 0 10 0 102 197 156 197;
#P connect 11 0 12 0;
#P connect 11 0 12 2;
#P fasten 1 0 0 0 71 112 71 112;
#P connect 3 0 1 1;
#P connect 2 0 1 0;
#P connect 13 0 14 0;
#P connect 14 0 15 0;
#P fasten 9 0 17 0 71 421 353 421 353 64 396 64;
#P connect 8 0 9 0;
#P connect 16 0 9 0;
#P fasten 5 0 0 0 163 109 71 109;
#P fasten 4 0 0 0 223 109 71 109;
#P connect 0 0 8 0;
#P connect 8 1 7 0;
#P connect 15 0 16 0;
#P connect 12 0 13 0;
#P connect 6 0 5 0;
#P window clipboard copycount 18;

Richard wrote:
> Thanks for this. This looks good but while I think I understand how it’s working I’ve not used JS before and am unsure how to actually implement it ?? I’ve looked through the JS tutorials – should I put this in a function and then call that function ? Can’t seem to get anything to work. Any pointers would be greatly appreciated.
>
> Thanks again,
> Richard.

#83519
Sep 18, 2006 at 9:04pm

Thanks for this. Until I get more familiar with Javascript I adapted Trond’s patch to load up the different jpegs and resize according to how many pictures. Still fairly slow but I guess that’s what to expect when loading up 200+ jpegs into a matrix.

Thanks for the help.
Richard.

max v2;
#N vpatcher 0 0 1152 788;
#P origin 0 -94;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 126 282 27 9109513 int;
#P newex 398 97 27 9109513 int;
#P newex 215 270 30 9109513 t b b;
#P message 440 351 114 9109513 exportimage test.jpg bmp;
#P newex 489 412 113 9109513 exportimage test.jpg jepg;
#P message 677 99 23 9109513 288;
#P message 142 78 26 9109513 stop;
#P newex 163 106 50 9109513 metro 150;
#P button 248 38 15 0;
#P newex 263 80 30 9109513 t b b;
#P message 8 103 14 9109513 1;
#P newex 7 78 45 9109513 loadbang;
#P message 301 459 28 9109513 clear;
#P button 381 195 15 0;
#P message 159 204 14 9109513 0;
#P number 405 127 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname counterno;
#P newex 409 177 57 9109513 prepend set;
#P newex 409 155 109 9109513 sprintf read %ld.jpeg.jpg;
#P message 403 211 79 9109513 read 288.jpeg.jpg;
#P number 166 266 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 50 333 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 170 335 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 740 507 57 9109513 prepend set;
#P window linecount 2;
#P message 741 532 50 9109513 47 35 47 35;
#P window linecount 1;
#P newex 739 480 107 9109513 sprintf %ld %ld %ld %ld;
#P comment 815 440 100 9109513 Height;
#P number 769 440 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 773 407 33 9109513 * 0.75;
#P button 744 321 15 0;
#P number 736 387 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 772 363 27 9109513 /;
#P message 744 342 23 9109513 800;
#P newex 801 311 27 9109513 + 1;
#P number 775 284 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 774 261 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 774 231 24 9109513 sqrt;
#P number 774 206 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user jit.pwindow 247 496 406 253 0 1 0 0 1 0;
#P message 95 448 175 9109513 dstdimstart $1 $2 , dstdimend $3 $4;
#P newex 97 425 66 9109513 Lsub 0 0 1 1;
#P newex 97 400 107 9109513 Lmult 75 200 75 200;
#P newex 97 374 66 9109513 Ladd 0 0 1 1;
#P newex 97 348 66 9109513 pack 0 0 0 0;
#P newex 93 308 27 9109513 % 4;
#P newex 150 312 27 9109513 / 4;
#P newex 46 484 172 9109513 jit.matrix 4 char 800 600 @usedstdim 1;
#P newex 55 215 27 9109513 t l b;
#N counter 0 0 15;
#X flags 0 0;
#P newobj 104 236 77 9109513 counter 0 0 15;
#P toggle 9 124 15 0;
#P newex 9 144 63 9109513 qmetro 100;
#P newex 5 181 81 9109513 jit.qt.movie 50 37;
#B color 5;
#P window linecount 2;
#P comment 775 170 100 9109513 Total Number of Pictures;
#P window linecount 1;
#P comment 837 311 100 9109513 so none are missed ??;
#P comment 811 388 100 9109513 Width;
#P window linecount 0;
#P comment -61 -18 100 9109513;
#P fasten 5 0 4 0 14 174 10 174;
#P connect 36 0 4 0;
#P connect 43 0 44 0;
#P connect 44 0 6 0;
#P connect 6 0 5 0;
#P connect 4 0 9 0;
#P connect 16 0 9 0;
#P connect 42 0 9 0;
#P connect 51 0 9 0;
#P connect 11 0 34 0;
#P connect 4 0 8 0;
#P connect 54 0 11 0;
#P connect 15 0 16 0;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 15 0;
#P connect 47 0 7 0;
#P connect 20 0 11 1;
#P connect 10 0 12 1;
#P connect 52 1 54 0;
#P connect 11 0 12 2;
#P connect 7 2 48 0;
#P connect 7 0 54 1;
#P connect 54 0 10 0;
#P connect 10 0 12 3;
#P connect 40 0 7 3;
#P connect 45 1 40 0;
#P connect 45 0 47 0;
#P connect 48 0 47 0;
#P connect 7 0 35 0;
#P connect 20 0 10 1;
#P connect 18 0 7 4;
#P connect 10 0 33 0;
#P connect 30 0 14 1;
#P connect 7 0 52 0;
#P fasten 9 0 17 0 51 515 55 515 55 519 253 519;
#P connect 46 0 45 0;
#P connect 45 1 42 0;
#P connect 38 0 41 0;
#P connect 52 0 53 0;
#P connect 38 0 36 0;
#P connect 41 0 36 0;
#P connect 53 0 39 0;
#P connect 39 0 37 0;
#P connect 37 0 38 0;
#P connect 7 0 53 1;
#P connect 24 0 25 0;
#P connect 25 0 30 0;
#P connect 30 0 32 0;
#P connect 32 0 31 0;
#P connect 21 0 26 0;
#P connect 26 0 23 0;
#P connect 27 0 28 0;
#P connect 28 0 30 1;
#P connect 23 0 24 0;
#P connect 25 0 27 0;
#P connect 49 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 20 0;
#P connect 20 0 21 0;
#P connect 22 0 24 1;
#P connect 21 0 22 0;
#P connect 25 0 30 2;
#P connect 28 0 30 3;
#P pop;

#83520

You must be logged in to reply to this topic.