diagonal submatrix


    Sep 25 2006 | 9:15 pm
    Hi all-
    For the piece I'm programming, I would like to take a 720x1 submatrix from my 720x480 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

    • Sep 25 2006 | 9:30 pm
      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
    • Sep 25 2006 | 9:39 pm
      On Sep 25, 2006, at 2:15 PM, mzed wrote:
      > For the piece I'm programming, I would like to take a 720x1 > submatrix from my 720x480 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
    • Sep 25 2006 | 9:39 pm
      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 720x1 > submatrix from my 720x480 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.9990x314 > || http://www.cnmat.berkeley.edu/ > || http://www.piratelemur.com/ > > > >
    • Sep 25 2006 | 9:43 pm
      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
    • Sep 25 2006 | 9:48 pm
      Wow, I had no idea you could do that. Guess that makes my object completely redundant:
    • Sep 25 2006 | 10:12 pm
      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
    • Sep 26 2006 | 2:30 am
      > 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