# Homographic mapping of centroid

This topic is 2915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there,

I would like to know if a centroid of points is mapped to the new centroid if the points are mapped via a homography.
How is a centroid determined when using 2D-homographic coordinates.
Lets assume X1 = [1,0,1]' and X2 = [2,1,1]'. The centroid should still be 0.5(X1+X2), right?

X1 = [1,0,1]';X2 = [2,1,1]';Xm = [1.5, 0.5, 1]';H = [1,1,10;2.3,2,20;0.4,1,1];X_1 = H*X1;X_2 = H*X2;X_m = 0.5*(X_1+X_2);result = H*Xm - X_m;

In fact the result 0. So it seems that the centroid is mapped to the centroid. Is this somehow a lucky case or is this the case in general?

The only thing I see, that the third entry of the vectors have to be 1.

Michael

##### Share on other sites
Quote:
 Original post by Michael02I would like to know if a centroid of points is mapped to the new centroid if the points are mapped via a homography.

No, this is not generally true. Centroids are preserved by affine transformations only.

##### Share on other sites
Is there a proof somewhere, like something official?
I need something to quote ;-)

Thank you,

Michael

##### Share on other sites
You can just create an example where the centroid is not preserved. Pick a homography that is not an affine transformation (the projection of the floor on a vertical painting will do). Then pick two points and compute their centroid before and after the transformation. You'll see that those points don't map to each other.

Think about this situation. You are standing on a floor which is an infinite plane. Ahead of you in some direction there are three points at a distance of 100m, 300m and 500m. Now put a canvas in front of you and draw what you see. Will those points be equidistant in your painting?

##### Share on other sites
Quote:
 Original post by alvaroYou can just create an example where the centroid is not preserved. Pick a homography that is not an affine transformation (the projection of the floor on a vertical painting will do). Then pick two points and compute their centroid before and after the transformation. You'll see that those points don't map to each other.

That's what I expect too, but it turns out, that no matter what I do, it works.
Here is some Matlab-code:

X1 = [1,0,1]';
X2 = [2,1,1]';
C = 0.5*(X1+X2);
H = rand(3,3);
X_1 = H*X1;
X_2 = H*X2;
C_ = 0.5*(X_1+X_2);
diff = H*C - C_

H*C is the projected center and C_ is the center of the projected points.
I tried it several time but it always works. Is there a mistake?

Thanks,

Michael

##### Share on other sites
Remember to divide by the third component after you multiply by H. You can only compute the centroid after you make the third coordinate 1.

##### Share on other sites
Quote:
 Original post by alvaroRemember to divide by the third component after you multiply by H. You can only compute the centroid after you make the third coordinate 1.

Sure, but it doesn't really matter as H*C and C_ have the same values.
Here is the complete output:

>> X1 = [1,0,1]'X2 = [2,1,1]'C = 0.5*(X1+X2)H = rand(3,3)X_1 = H*X1X_2 = H*X2C_ = 0.5*(X_1+X_2)HC = H*Cdiff = HC - C_X1 =     1     0     1X2 =     2     1     1C =    1.5000    0.5000    1.0000H =    0.8143    0.3500    0.6160    0.2435    0.1966    0.4733    0.9293    0.2511    0.3517X_1 =    1.4303    0.7168    1.2809X_2 =    2.5946    1.1569    2.4613C_ =    2.0125    0.9369    1.8711HC =    2.0125    0.9369    1.8711diff =     0     0     0

##### Share on other sites
Quote:
Original post by Michael02
Quote:
 Original post by alvaroRemember to divide by the third component after you multiply by H. You can only compute the centroid after you make the third coordinate 1.

Sure, but it doesn't really matter as H*C and C_ have the same values.

No, it matters a lot.

Quote:
 X_1 = 1.4303 0.7168 1.2809X_2 = 2.5946 1.1569 2.4613

You should now take the representations of those points whose third coordinate is 1, which are

Y_1 =
1.1166
0.5596
1.0000

Y_2 =
1.0542
0.4700
1.0000

Then you take the average.

Dividing by the third coordinate is the key non-linear step that breaks things.

##### Share on other sites
Ah! Now I get it.
Thanks a lot!
It seems that I am not really familiar with homogeneous coordinates.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007526
• ### Who's Online (See full list)

There are no registered users currently online

×