(Simple) Jitter Color Picking Question

Aug 30, 2013 at 5:51pm

(Simple) Jitter Color Picking Question

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?

#263786
Aug 31, 2013 at 2:45am

This is the first solution that comes to mind…
<code>

– Pasted Max Patch, click to expand. –

</code>

#263803
Aug 31, 2013 at 4:30am

That’s…..awesome!

Here is my tweaked version that packs the current selection into a coll, ready for use.

<code>

– Pasted Max Patch, click to expand. –

</code>

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.

#263805
Aug 31, 2013 at 4:47am

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)

<code>

– Pasted Max Patch, click to expand. –

</code>

#263806
Aug 31, 2013 at 5:55am

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

<code>

– Pasted Max Patch, click to expand. –

</code>

#263808
Aug 31, 2013 at 6:17am

@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).

#263810
Aug 31, 2013 at 6:19am

(nevermind, just saw jit.matrixinfo)

#263811
Aug 31, 2013 at 6:25am

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…)

#263813
Aug 31, 2013 at 7:03am

Exactly, I offset everything. Haven’t implemented the dynamic sizing but here is the centered pointer and everything commented.

<code>

– Pasted Max Patch, click to expand. –

</code>

#263814
Aug 31, 2013 at 10:34am

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.

#263843
Sep 2, 2013 at 11:39am

nice work! maybe you want to submit it to the toolbox or the wiki so it doesn’t get lost in the forum.

#264027
Sep 2, 2013 at 11:42am

Good idea!

lska did do the initial heavy lifting though I can upload it if he doesn’t mind.

#264029

You must be logged in to reply to this topic.