BUG: matrix interpolation doesn't work properly

lists@lowfrequency.or's icon

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)

Max Patch
Copy patch and select New From Clipboard in Max.

Best,
Evan

lists@lowfrequency.or's icon

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

Joshua Kit Clayton's icon

>
> 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

Max Patch
Copy patch and select New From Clipboard in Max.


lists@lowfrequency.or's icon

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