## diagonal submatrix

Sep 25, 2006 at 9:15pm

# diagonal submatrix

Hi all-

For the piece I’m programming, I would like to take a 720×1 submatrix from my 720×480 video. jit.submatrix is fine, but I would also like to take diagonal lines. My current solution is to use jit.rota on the video, and then jit.submatrix to take a horizontal slice of the rotated matrix. Unfortunately, the effort to do that is overwhelming my whole patch (specifically, the USB bus is backlogging).

So, I’m looking for a cheaper solution. Downsampling works, but is not the most desirable. Other possibilities that I see are either moving off into OpenGL or pulling my diagonal lines pixel by pixel from the video.

I wonder if anyboy has any thoughts about those ideas, or better suggestions. I don’t want to spend too much time barking up the wrong tree; the concert is fast approaching.

mz

#27788
Sep 25, 2006 at 9:39pm

On Sep 25, 2006, at 2:15 PM, mzed wrote:

> For the piece I’m programming, I would like to take a 720×1
> submatrix from my 720×480 video. jit.submatrix is fine, but I
> would also like to take diagonal lines. My current solution is to
> use jit.rota on the video, and then jit.submatrix to take a
> horizontal slice of the rotated matrix. Unfortunately, the effort
> to do that is overwhelming my whole patch (specifically, the USB
> bus is backlogging).

The way I’d do this is: jit.repos @adapt 0 @dim 720 1

Right hand input should be something like exprfill “dim[0]” sent to
jit.matrix 2 long 720 1

However, keep in mind that jit.rota (and the other spatial operators
like mxform2d and resamp) could work for you too, if you use @adapt 0
and @dim 720 1. jit.rota doesn’t require that the output dimensions
map the input dimensions, and it will only calculate the *output
pixels*. This more efficient strategy alleviates any need for
jit.submatrix, and is generally a good trick to know. The repos
method will be a tad faster, and perhaps less prone to round off
error while rotating, but it might be more difficult for you to
perform arbitrary rotations in which case I’d recommend jit.rota
(probably with @interp 1).

-Joshua

#84541
Sep 25, 2006 at 9:39pm

jit.repos should work well.

-Randy

On Sep 25, 2006, at 2:15 PM, mzed wrote:

>
> Hi all-
>
> For the piece I’m programming, I would like to take a 720×1
> submatrix from my 720×480 video. jit.submatrix is fine, but I
> would also like to take diagonal lines. My current solution is to
> use jit.rota on the video, and then jit.submatrix to take a
> horizontal slice of the rotated matrix. Unfortunately, the effort
> to do that is overwhelming my whole patch (specifically, the USB
> bus is backlogging).
>
> So, I’m looking for a cheaper solution. Downsampling works, but is
> not the most desirable. Other possibilities that I see are either
> moving off into OpenGL or pulling my diagonal lines pixel by pixel
> from the video.
>
> I wonder if anyboy has any thoughts about those ideas, or better
> suggestions. I don’t want to spend too much time barking up the
> wrong tree; the concert is fast approaching.
>
> mz
>
> –
> || michael f. zbyszynski — molecular gastronimist
> || mzed@cnmat.berkeley.edu — +1.510.643.9990×314
> || http://www.cnmat.berkeley.edu/
> || http://www.piratelemur.com/
>
>
>
>

#84542
Sep 25, 2006 at 9:43pm

On Sep 25, 2006, at 2:39 PM, Joshua Kit Clayton wrote:

> Right hand input should be something like exprfill “dim[0]” sent to
> jit.matrix 2 long 720 1

Sorry “dim[0]” should read “cell[0]” in the above.

-Joshua

#84543
Sep 25, 2006 at 10:12pm

On Sep 25, 2006, at 2:48 PM, Wesley Smith wrote:

> Wow, I had no idea you could do that. Guess that makes my object
> completely redundant:

Unless your objects supports dimcount > 2, which if I recall
correctly was one of the jit.repos limitations which led you to work
on this and the timecube object.

-Joshua

#84545
Sep 26, 2006 at 2:30am

> The way I’d do this is: jit.repos @adapt 0 @dim 720 1
>
> Right hand input should be something like exprfill “dim[0]” sent to
> jit.matrix 2 long 720 1
>
> However, keep in mind that jit.rota (and the other spatial operators
> like mxform2d and resamp) could work for you too…

Great, thanks. I knew there was a third half to the tip you had given me earlier.

jit.rota fit my mental and aesthetic needs just fine, and is now hella effecient.

BTW: I remember, when reading the jit.matrix docs, that I should pay attention to these attributes for all matrix-dealing objects. Of course, I didn’t remember. Although it’s handy for the doc developers to have these dealt with all in one place, maybe some clues for the forgetful would be good, too.

Anyhow, brilliant tip.

mz

#84546

You must be logged in to reply to this topic.