Populating jit.gl.multiple with centroid coords?

Nov 23, 2011 at 8:38pm

Populating jit.gl.multiple with centroid coords?

Hey,
I’m trying to draw circles corresponding not only to the center of blob masses, but with the size of the circle reflecting the blob area. So, bigger person -> bigger blob -> bigger circle (at the same coordinates).
Here is what I have so far:

– Pasted Max Patch, click to expand. –

As you can see, it doesn’t work. I’m not sure where my problem is; should the position matrix be receiving different information, or is the scale matrix?

#60204
Nov 23, 2011 at 10:30pm

if you want the objects drawn by gl.multiple to reflect the size and position of the blobs, then of course you need to update both the scale and position matrix each frame.

the blobs matrix contains information about blobs in screen coordinates (2D pixel values), but the gl.multiple requires world coordinates (3D world-space values), so you must iterate the blobs matrix, call screentoworld for each cell and pack into a new matrix for the gl.multiple position input.

the area value of the blobs can be scaled into an appropriate value for the 3d shapes using simple math objects, or the scale object.

you also need to send a binary matrix to the centroids object (black and white, not greyscale) so you send it through a jit.op @op > for thresholding, to get a binary matrix output.

take a look at the patch below:

– Pasted Max Patch, click to expand. –
#216741
Nov 23, 2011 at 10:43pm

#216742
Nov 23, 2011 at 10:54pm

ahh, forgot about jit.map.
seems a much easier solution.
here’s previous patch with a jit.map solution.
notice you have to invert the y plane:

– Pasted Max Patch, click to expand. –
#216743
Nov 23, 2011 at 11:18pm
#216744
Nov 23, 2011 at 11:20pm

Can I ask you though, why jit.pack 3 that info for x and y? Is that the only acceptable form for the input matrix?

#216745
Nov 27, 2011 at 5:30pm

Here’s another solution that does the coordinate scaling based on video input size:

– Pasted Max Patch, click to expand. –
#216746
Nov 27, 2011 at 5:34pm

As always, thanks for your help!

#216747

You must be logged in to reply to this topic.