Populating jit.gl.multiple with centroid coords?

Nov 23, 2011 at 8:38pm

Populating jit.gl.multiple with centroid coords?

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?

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. –
Nov 23, 2011 at 10:43pm

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. –
Nov 23, 2011 at 11:18pm
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?

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. –
Nov 27, 2011 at 5:34pm

As always, thanks for your help!


You must be logged in to reply to this topic.