Sum and Average values of jit.submatrix plane

Casey Childers's icon

I'm developing a patch that works against the cell values of a matrix. For individual cells I'm set, but I'm stuck on an enhancement. As it works presently, I traverse individual pixels and pull a scalar value for each color plane. I'm now interested in capturing a range of cells, I'm currently using `jit.submatrix` with `dim` and `offset`, and visually it's great.

The goal of this enhancement, though, is to generate an average of the pixel values of the submatrix plane.

outputting submatrix plane to cellblock

I'm at a loss on how to proceed in Max. It would be pretty easy in most languages, so I figure this is just how new I am. I can't seem to dump the table to a list—though, even if I pulled that off I'm not sure how I could easily say `sum(values)/entries` in the patcher. I've only done really basic math operations thus far with a fixed number operands.

Any help dumping all cells to a list would be a life saver. And help on the expression would be icing. Thanks for your time.

Rob Ramirez's icon

i believe jit.dimop and jit.planeop may be useful.

otherwise look at jit.iter and jit.spill to retrieve the contents of matrices as number streams / lists.

Jean-Francois Charles's icon

Also, for a quick average, jit.3m. So, maybe in your case jit.submatrix -> jit.3m.

Casey Childers's icon

Thank you so much, Rob and Jean-Francois! Exactly what I was looking for.