Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Alignment of 3D Points

Subject: Alignment of 3D Points

From: Anusha

Date: 14 Dec, 2012 04:06:08

Message: 1 of 11

I have two sets of 3d points (in x,y,z) coordinates. How can I align these two points into a same reference point, maybe using a centroid?

Thanks

Subject: Alignment of 3D Points

From: Matt J

Date: 14 Dec, 2012 04:30:08

Message: 2 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kae8jg$rao$1@newscl01ah.mathworks.com>...
> I have two sets of 3d points (in x,y,z) coordinates. How can I align these two points into a same reference point, maybe using a centroid?
=============

You can use this,

http://www.mathworks.com/matlabcentral/fileexchange/26186-absolute-orientation-horns-method

Subject: Alignment of 3D Points

From: Roger Stafford

Date: 14 Dec, 2012 04:49:09

Message: 3 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kae8jg$rao$1@newscl01ah.mathworks.com>...
> I have two sets of 3d points (in x,y,z) coordinates. How can I align these two points into a same reference point, maybe using a centroid?
>
> Thanks
- - - - - - - - -
  You may be interested in matlab's 'procrustes' function in the Statistics Toolbox. It determines the linear transformation of one set of points to another set that produces the least sum of squares differences between the two sets.

Roger Stafford

Subject: Alignment of 3D Points

From: Anusha

Date: 14 Dec, 2012 14:40:09

Message: 4 of 11

"Roger Stafford" wrote in message <kaeb45$4j0$1@newscl01ah.mathworks.com>...
> "Anusha " <anusha@cs.usm.my> wrote in message <kae8jg$rao$1@newscl01ah.mathworks.com>...
> > I have two sets of 3d points (in x,y,z) coordinates. How can I align these two points into a same reference point, maybe using a centroid?
> >
> > Thanks
> - - - - - - - - -
> You may be interested in matlab's 'procrustes' function in the Statistics Toolbox. It determines the linear transformation of one set of points to another set that produces the least sum of squares differences between the two sets.
>
> Roger Stafford

But I have different number of point for set A and set B. Can procrustes can be done on this case? I prefer to align them to a standard coordinate system, let say mayb on a given center of gravity.

Subject: Alignment of 3D Points

From: Matt J

Date: 14 Dec, 2012 15:38:08

Message: 5 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kafdo9$cub$1@newscl01ah.mathworks.com>...
>
> But I have different number of point for set A and set B. Can procrustes can be done on this case? I prefer to align them to a standard coordinate system, let say mayb on a given center of gravity.
=================

Assuming A is 3xN and B is 3xM, you can translate the centroid of B to coincide with the centroid of A as follows

 Bnew=bsxfun(@plus,B,mean(A,2)-mean(B,2));

It's not clear, though, why you're only asking about aligning the centroids. What information is there about the rotation of A relative to B and why don't you care about it?

Subject: Alignment of 3D Points

From: Anusha

Date: 14 Dec, 2012 16:18:08

Message: 6 of 11

"Matt J" wrote in message <kafh50$onj$1@newscl01ah.mathworks.com>...
> "Anusha " <anusha@cs.usm.my> wrote in message <kafdo9$cub$1@newscl01ah.mathworks.com>...
> >
> > But I have different number of point for set A and set B. Can procrustes can be done on this case? I prefer to align them to a standard coordinate system, let say mayb on a given center of gravity.
> =================
>
> Assuming A is 3xN and B is 3xM, you can translate the centroid of B to coincide with the centroid of A as follows
>
> Bnew=bsxfun(@plus,B,mean(A,2)-mean(B,2));
>
> It's not clear, though, why you're only asking about aligning the centroids. What information is there about the rotation of A relative to B and why don't you care about it?

Actually what I need to do is aligning A and B into a standard coordinate system. When I say aligning to the centroid, it means that during aligning A and B to standard coordinate, maybe the centroid of either A or B can be utilized to give the center of gravity for alignment. Hope Im making myself clear.

Subject: Alignment of 3D Points

From: Matt J

Date: 14 Dec, 2012 16:40:09

Message: 7 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kafjg0$3ta$1@newscl01ah.mathworks.com>...
>
> Actually what I need to do is aligning A and B into a standard coordinate system. When I say aligning to the centroid, it means that during aligning A and B to standard coordinate, maybe the centroid of either A or B can be utilized to give the center of gravity for alignment. Hope Im making myself clear.
============

No, I'm afraid not. What makes you think A and B aren't already measured in the same coordinate system right now? After all, they're already both in R^3 and R^3 is a pretty standard coordinate system.

Is A a transformation of B? If so, what does that transformation look like and why aren't there the same number of points before and after the transformation?

Subject: Alignment of 3D Points

From: Roger Stafford

Date: 14 Dec, 2012 20:28:08

Message: 8 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kafjg0$3ta$1@newscl01ah.mathworks.com>...
> Actually what I need to do is aligning A and B into a standard coordinate system. When I say aligning to the centroid, it means that during aligning A and B to standard coordinate, maybe the centroid of either A or B can be utilized to give the center of gravity for alignment. Hope Im making myself clear.
- - - - - - - - - -
  Anusha, you still haven't defined to my satisfaction what you mean by "aligning A and B into a standard coordinate system" where A and B are two sets of points. Just what do you mean by this? Taken by itself it is not a description that I am familiar with.

  The only thing I can think of that you might conceivably mean is to locate the centroid of each set at the origin of a system of cartesian coordinates and align their three principal moments of inertia with the coordinate axes with, say, the largest moment along the x-axis and smallest along the z-axis, assuming the points have equal mass - or something like that.

  In answer to your question about procrustes, yes, it does require that the two sets have the same number of points. That is needed to make sense out of the kind of processing that it performs.

Roger Stafford

Subject: Alignment of 3D Points

From: Anusha

Date: 15 Dec, 2012 15:43:08

Message: 9 of 11

"Matt J" wrote in message <kafkp8$83i$1@newscl01ah.mathworks.com>...
> "Anusha " <anusha@cs.usm.my> wrote in message <kafjg0$3ta$1@newscl01ah.mathworks.com>...
> >
> > Actually what I need to do is aligning A and B into a standard coordinate system. When I say aligning to the centroid, it means that during aligning A and B to standard coordinate, maybe the centroid of either A or B can be utilized to give the center of gravity for alignment. Hope Im making myself clear.
> ============
>
> No, I'm afraid not. What makes you think A and B aren't already measured in the same coordinate system right now? After all, they're already both in R^3 and R^3 is a pretty standard coordinate system.
>
> Is A a transformation of B? If so, what does that transformation look like and why aren't there the same number of points before and after the transformation?

Actually A and B represents points on a surface of medical structure. Capturing the medical structure at different time wil not provide an aligned point set representastion. I have checked this, and the structure A and B are not aligned at the same axis. thts why I need to aligned them to a common axis/center of gravity so tht further processing can be done.

Subject: Alignment of 3D Points

From: Roger Stafford

Date: 16 Dec, 2012 01:15:10

Message: 10 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kai5qc$1ad$1@newscl01ah.mathworks.com>...
> Actually A and B represents points on a surface of medical structure. Capturing the medical structure at different time wil not provide an aligned point set representastion. I have checked this, and the structure A and B are not aligned at the same axis. thts why I need to aligned them to a common axis/center of gravity so tht further processing can be done.
- - - - - - - - - -
  You are still making that same statement without defining what you mean! You have said, "I need to aligned them to a common axis/center of gravity". A set of points does have a centroid, we can agree on that, but that still leaves the point set with two degrees of freedom to rotate about that centroid. What do you mean by the "common axis" of the sets? I suggested using their principal moments of inertia which would indeed define a canonical set of orthogonal axes, provided all three were different, but so far you haven't responded to that suggestion. Do you have any other inherent axes that can be associated with a 3D point set? To put the question loosely, which way is inherently "up", which way is "in front", and which way is "to the side" for an abstract set of three-dimensional points of arbitrary orientation in some coordinate system?

Roger Stafford

Subject: Alignment of 3D Points

From: Matt J

Date: 16 Dec, 2012 07:46:15

Message: 11 of 11

"Anusha " <anusha@cs.usm.my> wrote in message <kai5qc$1ad$1@newscl01ah.mathworks.com>...
>
> > Is A a transformation of B? If so, what does that transformation look like and why aren't there the same number of points before and after the transformation?
>
> Actually A and B represents points on a surface of medical structure. Capturing the medical structure at different time wil not provide an aligned point set representastion.
================


If you're dong surface-to-surface registration, there are some possibly applicable contributions on the FEX. Some examples are

http://www.mathworks.com/matlabcentral/fileexchange/27804-iterative-closest-point

http://www.mathworks.com/matlabcentral/fileexchange/12627-iterative-closest-point-method

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us