[vtkusers] Landmark Transform + ICP

Massinissa Bandou Massinissa.Bandou at USherbrooke.ca
Mon Jun 17 13:15:50 EDT 2013


Hi David, 
IT WORKS!!! with some modification according to this examples:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/AlignFrames

1- I decided to use the position of the first source landmark as an origin
and get the X direction and Y direction from second and third source
landmarks position and use the cross product to get the Z direction.

2- Repeat the previous step with target landmarks.

3- Get the 4x4 matrix from the x,y,z direction(column) from the source
landmarks and use the position of the source origin as a vector of
translation and invert the matrix.

4- Get the 4x4 matrix from the x,y,z direction(column) from the target
landmarks, use the target position of the landmarks origin as vector of
translation.

5- Multiply the two matrix(4*3) to get the global transformation.

6- Apply the ICP to reduce the error generated from the correspondent
landmarks. 

struct MFrame
{
	MFrame(double p1[3], double p2[3], double p3[3]){
		this->setOrigin(p1);
		this->setXDirection(p2);
		this->setYDirection(p3);
		this->setZDirection();

		cout<<"Origin: "<<this->origin[0]<<" "<<this->origin[1]<<"
"<<this->origin[2]<<endl;
		cout&lt;&lt;&quot;X direction: &quot;&lt;&lt;this->XDirection[0]<<"
"<<this->XDirection[1]<<" "<<this->XDirection[2]<<endl;
		cout&lt;&lt;&quot;Y direction: &quot;&lt;&lt;this->YDirection[0]<<"
"<<this->YDirection[1]<<" "<<this->YDirection[2]<<endl;
		cout&lt;&lt;&quot;Z direction: &quot;&lt;&lt;this->ZDirection[0]<<"
"<<this->ZDirection[1]<<" "<<this->ZDirection[2]<<endl;
	}

	double origin[3];
	double XDirection[3];
	double YDirection[3];
	double ZDirection[3];
	
	void setOrigin(double o[3]){
		this->origin[0] = o[0];
		this->origin[1] = o[1];
		this->origin[2] = o[2];
	}
	void setXDirection(double direction[3]){
		double a[3];
		vtkMath::Subtract(direction,this->origin,a);
		vtkMath::Normalize(a);
		this->XDirection[0] = a[0];
		this->XDirection[1] = a[1];
		this->XDirection[2] = a[2];
	}
	void setYDirection(double direction[3]){
		double a[3];
		vtkMath::Subtract(direction,this->origin,a);
		vtkMath::Normalize(a);
		this->YDirection[0] = a[0];
		this->YDirection[1] = a[1];
		this->YDirection[2] = a[2];
	}
	void setZDirection(){
		double a[3];
		vtkMath::Cross(this->XDirection,this->YDirection,a);
		vtkMath::Normalize(a);
		this->ZDirection[0] = a[0];
		this->ZDirection[1] = a[1];
		this->ZDirection[2] = a[2];
	}
};




--
View this message in context: http://vtk.1045678.n5.nabble.com/Landmark-Transform-ICP-tp5721129p5721451.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list