BUG: matrix interpolation doesn't work properly

Aug 23, 2006 at 1:15pm

BUG: matrix interpolation doesn't work properly

Bug report: Under certain circumstances (one in particular), a
jit.matrix will not interpolate properly.
Max/jitter 4.5.7/1.5.2
OS X 10.4.6

Expected behavior:

When trying to interpolate to a single dimension (e.g. a 1xN matrix),
I expect the result to be a single-column matrix with each cell of
the column containing an average of the entire row it belongs to.

Observed behavior:

When trying to interpolate to a single dimension (e.g. a 1xN matrix),
the result is not an interpolated matrix but rather the 1st column of
the original matrix with no interpolation.

Example patch:
(Read in a movie or image, and observe the results. You should
notice that the jit.submatrix output is conspicuously identical to
the jit.matrix output)

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 73 53 80 196617 jump 300 , bang;
#P user jit.pwindow 68 105 82 82 0 0 0 0 0 0;
#P message 31 30 50 196617 read;
#P newex 206 148 50 196617 sel 1;
#P newex 206 124 50 196617 zl rot 1;
#P newex 206 101 57 196617 route read;
#P newex 49 78 167 196617 jit.qt.movie 320 240 @autostart 0;
#P user jit.pwindow 326 237 82 82 0 0 0 0 0 0;
#P newex 327 209 221 196617 jit.submatrix @dim 1 512 @offset 0 0;
#B color 7;
#P user jit.pwindow 48 248 82 82 0 0 0 0 0 0;
#P window linecount 2;
#P newex 49 206 221 196617 jit.matrix squish 4 char 1 240 @adapt 0
@interp 1;
#B color 7;
#P connect 4 0 0 0;
#P connect 4 0 9 0;
#P fasten 4 0 2 0 54 192 332 192;
#P connect 0 0 1 0;
#P connect 10 0 4 0;
#P connect 8 0 4 0;
#P fasten 7 0 4 0 211 171 269 171 269 49 54 49;
#P connect 4 1 5 0;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 2 0 3 0;
#P window clipboard copycount 11;

Best,
Evan

#27271
Aug 23, 2006 at 1:19pm

Oops, the jit.submatrix should be @dim 1 240, NOT @dim 1 512. But
the result is the same, no need to change it, I just didn’t want to
confuse anyone. (Sorry, copied and pasted out of another patch).

Best,
Evan

#82310
Aug 23, 2006 at 6:00pm

>
> Expected behavior:
> When trying to interpolate to a single dimension (e.g. a 1xN
> matrix), I expect the result to be a single-column matrix with each
> cell of the column containing an average of the entire row it
> belongs to.
>
> Observed behavior:
> When trying to interpolate to a single dimension (e.g. a 1xN
> matrix), the result is not an interpolated matrix but rather the
> 1st column of the original matrix with no interpolation.

This is not a bug. This is how pointwise linear interpolation works.
It is not an averaging filter. For more on the subject, I’d suggest
searching online.

If you want to average all elements in a column/row, etc, I would
suggest you iterate, downsampling by two and averaging each time.
Below is an example, but it only works exactly right for power of two
matrices.

-Joshua

#P window setfont “Sans Serif” 9.;
#P user jit.fpsgui 137 84 60 196617 0;
#P toggle 129 33 15 0;
#P window linecount 1;
#P newex 129 58 42 196617 qmetro;
#P user jit.pwindow 213 251 82 258 0 1 0 0 1 0;
#P user jit.pwindow 327 427 258 82 0 1 0 0 1 0;
#P newex 328 371 68 196617 jit.normalize;
#P user jit.pwindow 327 251 258 82 0 1 0 0 1 0;
#N vpatcher 40 104 640 504;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 331 276 158 196617 only works for powers of two;
#P comment 332 51 124 196617 split every other row;
#P comment 332 235 203 196617 keep doing until you reach a dim size
of 1.;
#P newex 239 73 72 196617 jit.matrixinfo;
#P newex 183 231 27 196617 + 1;
#P newex 183 207 30 196617 < = 1;
#P newex 183 181 58 196617 unpack 0 0;
#P newex 183 158 53 196617 route dim;
#P newex 183 131 72 196617 jit.matrixinfo;
#P newex 50 283 109 196617 gate 2 1;
#P newex 149 101 74 196617 jit.op @op avg;
#P newex 149 50 164 196617 jit.demultiplex @demultiplexdim 1;
#P inlet 149 30 15 0;
#P outlet 149 305 15 0;
#P window linecount 0;
#P comment 332 76 100 196617 adapt to right input;
#P connect 10 0 5 0;
#P connect 2 0 3 0;
#P fasten 5 0 3 0 55 310 17 310 17 45 154 45;
#P connect 11 0 4 0;
#P connect 3 0 4 0;
#P connect 4 0 5 1;
#P connect 5 1 1 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 8 1 9 0;
#P connect 9 0 10 0;
#P connect 3 1 4 1;
#P connect 3 1 11 0;
#P pop;
#P newobj 328 221 100 196617 p downsample_dim1;
#P user jit.pwindow 100 251 82 258 0 1 0 0 1 0;
#P newex 101 522 68 196617 jit.normalize;
#P button 85 79 15 0;
#N vpatcher 40 104 640 504;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 331 276 158 196617 only works for powers of two;
#P comment 332 51 124 196617 split every other column;
#P comment 332 235 124 196617 keep doing until you reach a dim size
of 1.;
#P newex 239 73 72 196617 jit.matrixinfo;
#P newex 183 231 27 196617 + 1;
#P newex 183 207 30 196617 < = 1;
#P newex 183 181 58 196617 unpack 0 0;
#P newex 183 158 53 196617 route dim;
#P newex 183 131 72 196617 jit.matrixinfo;
#P newex 50 283 109 196617 gate 2 1;
#P newex 149 101 74 196617 jit.op @op avg;
#P newex 149 50 164 196617 jit.demultiplex @demulitplexdim 0;
#P inlet 149 30 15 0;
#P outlet 149 305 15 0;
#P window linecount 0;
#P comment 332 76 100 196617 adapt to right input;
#P connect 10 0 5 0;
#P fasten 5 0 3 0 55 310 17 310 17 45 154 45;
#P connect 2 0 3 0;
#P connect 11 0 4 0;
#P connect 3 0 4 0;
#P connect 4 0 5 1;
#P connect 5 1 1 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 10 0;
#P connect 3 1 4 1;
#P connect 3 1 11 0;
#P pop;
#P newobj 101 221 100 196617 p downsample_dim0;
#P newex 101 118 121 196617 jit.noise 4 char 256 256;
#P connect 10 0 0 0;
#P connect 10 0 12 0;
#P connect 7 0 8 0;
#P connect 6 0 7 0;
#P connect 5 0 6 0;
#P connect 0 0 1 0;
#P connect 0 0 5 0;
#P fasten 3 0 9 0 106 547 194 547 194 247 219 247;
#P connect 11 0 10 0;
#P connect 4 0 3 0;
#P connect 1 0 4 0;
#P connect 2 0 0 0;
#P window clipboard copycount 13;

#82311
Aug 24, 2006 at 10:00am

Sorry, I misunderstood what the effects of interpolation would
actually be – sometimes you don’t realize that you have the wrong
impression of something until you’ve actually tried to code it…

Thanks for the example patch, it’s very helpful.

Best,
Evan

#82312

You must be logged in to reply to this topic.