15 #include "itkPSMProcrustesRegistration.h" 19 template<
unsigned int VDimension>
21 PSMProcrustesRegistration<VDimension>
22 ::RunRegistration(
int d)
25 const int totalDomains = m_PSMParticleSystem->GetNumberOfDomains();
26 const int numPoints = m_PSMParticleSystem->GetNumberOfParticles(0);
27 const int numShapes = totalDomains / m_DomainsPerShape;
29 ShapeListType shapelist;
30 ShapeType shapevector;
34 for (
int i = d % m_DomainsPerShape; i < totalDomains; i+=m_DomainsPerShape)
38 for (j = 0; j < numPoints; j++)
40 for (
unsigned int k = 0; k < VDimension; k++)
42 point(k) = m_PSMParticleSystem->GetPosition(j,i)[k];
44 shapevector.push_back(point);
46 shapelist.push_back(shapevector);
50 SimilarityTransformListType transforms;
52 typename PSMProcrustesFunctionType::Pointer procrustes = PSMProcrustesFunctionType::New();
53 procrustes->RunGeneralizedProcrustes(transforms, shapelist);
55 int k = d % m_DomainsPerShape;
56 for (
int i = 0; i < numShapes; i++, k += m_DomainsPerShape)
63 if (m_Scaling ==
true)
65 R(0,0) = transforms[i].rotation(0,0) * transforms[i].scale;
66 R(1,0) = transforms[i].rotation(1,0) * transforms[i].scale;
67 R(2,0) = transforms[i].rotation(2,0) * transforms[i].scale;
70 R(0,1) = transforms[i].rotation(0,1) * transforms[i].scale;
71 R(1,1) = transforms[i].rotation(1,1) * transforms[i].scale;
72 R(2,1) = transforms[i].rotation(2,1) * transforms[i].scale;
75 R(0,2) = transforms[i].rotation(0,2) * transforms[i].scale;
76 R(1,2) = transforms[i].rotation(1,2) * transforms[i].scale;
77 R(2,2) = transforms[i].rotation(2,2) * transforms[i].scale;
80 R(0,3) = transforms[i].translation(0) * R(0,0) + transforms[i].translation(1) * R(0,1) + transforms[i].translation(2) * R(0,2);
81 R(1,3) = transforms[i].translation(0) * R(1,0) + transforms[i].translation(1) * R(1,1) + transforms[i].translation(2) * R(1,2);
82 R(2,3) = transforms[i].translation(0) * R(2,0) + transforms[i].translation(1) * R(2,1) + transforms[i].translation(2) * R(2,2);
87 R(0,0) = transforms[i].rotation(0,0);
88 R(1,0) = transforms[i].rotation(1,0);
89 R(2,0) = transforms[i].rotation(2,0);
92 R(0,1) = transforms[i].rotation(0,1);
93 R(1,1) = transforms[i].rotation(1,1);
94 R(2,1) = transforms[i].rotation(2,1);
97 R(0,2) = transforms[i].rotation(0,2);
98 R(1,2) = transforms[i].rotation(1,2);
99 R(2,2) = transforms[i].rotation(2,2);
102 R(0,3) = transforms[i].translation(0) * R(0,0) + transforms[i].translation(1) * R(0,1) + transforms[i].translation(2) * R(0,2);
103 R(1,3) = transforms[i].translation(0) * R(1,0) + transforms[i].translation(1) * R(1,1) + transforms[i].translation(2) * R(1,2);
104 R(2,3) = transforms[i].translation(0) * R(2,0) + transforms[i].translation(1) * R(2,1) + transforms[i].translation(2) * R(2,2);
108 m_PSMParticleSystem->SetTransform(k, R);
109 std::cout <<
"R" << std::endl;
110 std::cout << R << std::endl;
111 std::cout << std::endl;
113 else if( VDimension == 2 )
115 if (m_Scaling ==
true)
117 R(0,0) = transforms[i].rotation(0,0) * transforms[i].scale;
118 R(1,0) = transforms[i].rotation(1,0) * transforms[i].scale;
121 R(0,1) = transforms[i].rotation(0,1) * transforms[i].scale;
122 R(1,1) = transforms[i].rotation(1,1) * transforms[i].scale;
125 R(0,2) = transforms[i].translation(0) * R(0,0) + transforms[i].translation(1) * R(0,1);
126 R(1,2) = transforms[i].translation(0) * R(1,0) + transforms[i].translation(1) * R(1,1);
131 R(0,0) = transforms[i].rotation(0,0);
132 R(1,0) = transforms[i].rotation(1,0);
135 R(0,1) = transforms[i].rotation(0,1);
136 R(1,1) = transforms[i].rotation(1,1);
139 R(0,2) = transforms[i].translation(0) * R(0,0) + transforms[i].translation(1) * R(0,1);
140 R(1,2) = transforms[i].translation(0) * R(1,0) + transforms[i].translation(1) * R(1,1);
144 m_PSMParticleSystem->SetTransform(k, R);
145 std::cout <<
"R" << std::endl;
146 std::cout << R << std::endl;
147 std::cout << std::endl;
This class interfaces with the PSMProcrustesFunction class to register a list of point sets...