Forums > Jitter

Coordinates of centre of gravity

November 23, 2006 | 11:36 pm

Hi,

I want to analyze a matrix (1 plane, 2 dimensions) and get coordinates of the centre of gravity. I can’t really explain it much clearer but here’s an example of what I want:

input:

1 0 0
0 0 1
0 0 0

output:

x=1, y=0.5

Another example:

2 0 0
0 0 1
0 0 0

output:

x=0.66, y=0.33

…I hope this is clear?

I think that the calculations should be something like this:

(0 * sum of all cells in row 0/ sum of all cells in matrix) +
(1 * sum of all cells in row 1/ sum of all cells in matrix) +
etc. = y

… and of course the same thing goes for the columns.

But how can I do this efficiently?

- Tarik


November 23, 2006 | 11:49 pm


November 24, 2006 | 2:26 am

I think there might be an object in cv.jit that does this calculation
for you… cv.jit.centroid.

wes

On 11/23/06, Tarik wrote:
>
> Hi,
>
> I want to analyze a matrix (1 plane, 2 dimensions) and get coordinates of the centre of gravity. I can’t really explain it much clearer but here’s an example of what I want:
>
> input:
>
> 1 0 0
> 0 0 1
> 0 0 0
>
> output:
>
> x=1, y=0.5
>
> Another example:
>
> 2 0 0
> 0 0 1
> 0 0 0
>
> output:
>
> x=0.66, y=0.33
>
>
> …I hope this is clear?
>
> I think that the calculations should be something like this:
>
> (0 * sum of all cells in row 0/ sum of all cells in matrix) +
> (1 * sum of all cells in row 1/ sum of all cells in matrix) +
> etc. = y
>
> … and of course the same thing goes for the columns.
>
> But how can I do this efficiently?
>
>
> – Tarik
>


November 26, 2006 | 12:31 pm

I’m not sure yet on how to use FTM for this kind of calculations but I’ll find out. And thanks for the tip, ’cause FTM seems to be a BIG improvement in the max-world! I haven’t heard of it before…

– T


November 27, 2006 | 5:55 pm

cv.jit.centroids does do that. also tap.jit.sum, I think.


Viewing 5 posts - 1 through 5 (of 5 total)