Coordinates of centre of gravity

Nov 23, 2006 at 11:36pm

Coordinates of centre of gravity

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

#28858
Nov 23, 2006 at 11:49pm

#88985
Nov 24, 2006 at 2:26am

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
>

#88986
Nov 26, 2006 at 12:31pm

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

#88987
Nov 27, 2006 at 5:55pm

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

#88988

You must be logged in to reply to this topic.