(Simple) Jitter Color Picking Question

    Aug 31 2013 | 12:51 am
    So I've not done a ton with jitter, but recently I've been doing some color/DMX stuff. Nothing dynamic/video oriented, but just randomly selecting within a certain colorspace (currently stored as about 30 coll objects).
    What I have works fine, but it's a real pain in the butt to add more color swatches/palettes/spaces at the moment as it means creating new coll objects and adding accompanying routing objects.
    What would be much simpler is loading an image into a matrix, and then using some kind of pointer to select a section of that image to use as the color space.
    I had a look through the jitter tutorials but didn't see anything along those lines (color picker with adjustable pointer aperture).
    I don't want to do anything with jitter other than spit out a list of the colors inside the pointer. The actual 'stuff' will be happening in max. It's just the lookup/storage that I want to do in jitter.
    What objects should I be looking at to do this? Can you load arbitrarily sized/resolution images? Compressed images?

    • Aug 31 2013 | 9:45 am
      This is the first solution that comes to mind...
    • Aug 31 2013 | 11:30 am
      Here is my tweaked version that packs the current selection into a coll, ready for use.
      One thing I couldn't figure out how to do is have some kind of visual feedback of where the selection is coming from. Everything I laid on top of jitpwindow would block the dumpout. It's not terribly critical as this works, it would just be handy to see where it's coming from.
    • Aug 31 2013 | 11:47 am
      Some incorrect math to calculate the coll size. Here's a fixed version.
      So in terms of loading the first image, I need to know the image size (height/width) to tell the jit.matrix. Is there a way to determine that inside max? (ie loading a random image with dropfile, then having that importmovie into an appropriately sized matrix)
    • Aug 31 2013 | 12:55 pm
      I'm having trouble posting the patch... I'll try and attach it now. BTW, you can use @adapt 1 attribute in jit.matrix to have it automatically resized when importing an image. However, the actual mouse coords are taken from jit.pwindow, so you'll have to resize it as well. I'd suggest you to use jit.window instead, so resizing it won't mess up the patch layout.
      And...I added some visual feedback using jit.lcd. HTH
    • Aug 31 2013 | 1:17 pm
      @adapt, very handy, though I suppose that still leaves the problem of resizing the jit.window and jit.lcd dependent on incoming message size.
      I hate the 'two window' paradigm of jit.window, so I think I'd sooner live with a static image in a jit.pwindow.
      Is there the equivalent of info~ for images/movies, to know dimensions of a loaded image?
      I can just restrict myself to always use 1080/720 or whatever, and call it a day.
      I'll tweak this a bit and post a combined version as I added some extra math stuff so the mouse pointer is always in the middle of the selection window (as opposed to the top/right corner, which isn't visually intuitive).
    • Aug 31 2013 | 1:19 pm
      (nevermind, just saw jit.matrixinfo)
    • Aug 31 2013 | 1:25 pm
      EDIT: (about matrixinfo) Writing at the same moment!
      About the mouse pointer: I was thinking about centering it too, but this way the pointer wouldn't correspond to the area selected by jit.submatrix (unless you apply some math also to the @offset coords, I suppose...)
    • Aug 31 2013 | 2:03 pm
      Exactly, I offset everything. Haven't implemented the dynamic sizing but here is the centered pointer and everything commented.
    • Aug 31 2013 | 5:34 pm
      Ok, took a lot of patching to get this working right. My approach was was to keep the jit.pwindow and jit.lcd at 320/240 regardless of the actual image/matrix size. Took a lot of conversion all over the place to account for different aspect ratios, but it keeps the mouse centered and reshapes the jit.lcd appropriately too.
      Also labelled and tidied the shit out of it.
    • Sep 02 2013 | 6:39 pm
      nice work! maybe you want to submit it to the toolbox or the wiki so it doesn't get lost in the forum.
    • Sep 02 2013 | 6:42 pm
      Good idea!
      lska did do the initial heavy lifting though I can upload it if he doesn't mind.