Sign in to follow this  
Michael02

Homographic mapping of centroid

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.

Thanks for your help,

Michael

Share this post


Link to post
Share on other sites
Quote:
Original post by Michael02
I 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by alvaro
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.


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 this post


Link to post
Share on other sites
Quote:
Original post by alvaro
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.


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*X1
X_2 = H*X2
C_ = 0.5*(X_1+X_2)
HC = H*C
diff = HC - C_

X1 =
1
0
1


X2 =
2
1
1


C =
1.5000
0.5000
1.0000


H =
0.8143 0.3500 0.6160
0.2435 0.1966 0.4733
0.9293 0.2511 0.3517


X_1 =
1.4303
0.7168
1.2809


X_2 =
2.5946
1.1569
2.4613


C_ =
2.0125
0.9369
1.8711


HC =
2.0125
0.9369
1.8711


diff =
0
0
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Michael02
Quote:
Original post by alvaro
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.


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.2809


X_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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this