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:30pm

Well,
I have just the object for you: xray.jit.cellvalue. You can download
a UB version of the xray objects here:

http://www.mat.ucsb.edu/~whsmith/xray-mac-UB.zip

Here’s a patch that does exactly what you’re looking for. Of course,
you don’t have to keep banging the second inlet all of the time. I
just did it in the patch for convenience sake.

best,
wes

#P window setfont “Sans Serif” 9.;
#P user jit.fpsgui 72 371 60 196617 3;
#P user jit.pwindow 71 285 430 76 0 1 0 0 1 0;
#P window linecount 1;
#P newex 151 184 130 196617 jit.matrix 2 float32 720 1;
#P newex 151 206 163 196617 jit.expr @expr “cell[0]” “cell[1]“;
#P flonum 271 114 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 271 135 42 196617 rate $1;
#P message 158 113 91 196617 read dvducks.mov;
#P message 205 135 27 196617 stop;
#P message 171 135 31 196617 start;
#P flonum 114 114 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 72 114 15 0;
#P newex 72 134 52 196617 metro 30;
#P message 235 135 31 196617 clear;
#P newex 72 161 105 196617 jit.qt.movie 720 480;
#P newex 72 227 89 196617 xray.jit.cellvalue;
#P fasten 3 0 1 0 77 159 77 159;
#P connect 3 0 12 0;
#P connect 13 0 14 0;
#P connect 0 0 13 0;
#P connect 11 0 0 1;
#P connect 12 0 11 0;
#P connect 1 0 0 0;
#P fasten 9 0 1 0 276 156 77 156;
#P fasten 8 0 1 0 163 156 77 156;
#P fasten 7 0 1 0 210 156 77 156;
#P fasten 6 0 1 0 176 156 77 156;
#P fasten 2 0 1 0 240 156 77 156;
#P connect 10 0 9 0;
#P connect 5 0 3 1;
#P connect 4 0 3 0;
#P window clipboard copycount 15;

#84540
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 9:48pm

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

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 300 289 115 196617 jit.matrix 2 long 720 1;
#P user jit.fpsgui 139 438 60 196617 3;
#P user jit.pwindow 138 352 430 76 0 1 0 0 1 0;
#P newex 300 238 130 196617 jit.matrix 2 float32 720 1;
#P newex 300 260 163 196617 jit.expr @expr “cell[0]” “cell[1]“;
#P flonum 338 181 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 338 202 42 196617 rate $1;
#P message 225 180 91 196617 read dvducks.mov;
#P message 272 202 27 196617 stop;
#P message 238 202 31 196617 start;
#P flonum 181 181 35 9 0.5 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 139 181 15 0;
#P newex 139 201 52 196617 metro 30;
#P message 302 202 31 196617 clear;
#P newex 139 228 105 196617 jit.qt.movie 720 480;
#P newex 139 294 150 196617 jit.repos @adapt 0 @dim 720 1;
#P connect 15 0 0 1;
#P connect 11 0 15 0;
#P fasten 3 0 1 0 144 226 144 226;
#P connect 3 0 12 0;
#P connect 13 0 14 0;
#P connect 12 0 11 0;
#P fasten 9 0 1 0 343 223 144 223;
#P fasten 8 0 1 0 230 223 144 223;
#P fasten 7 0 1 0 277 223 144 223;
#P fasten 6 0 1 0 243 223 144 223;
#P fasten 2 0 1 0 307 223 144 223;
#P connect 10 0 9 0;
#P connect 5 0 3 1;
#P connect 4 0 3 0;
#P connect 1 0 0 0;
#P connect 0 0 13 0;
#P window clipboard copycount 16;

#84544
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.