3.3. Spatial alignment
Once the 3D matrix of voxels is available we will need to align
in a meaningful way all the shapes to be compared or averaged.
Absolute coordinates cannot be taken as a reliable guidance since
placement and posture of the person can change between subjects.
The solution we have used is to rotate each shape to place the origin
of coordinates at the center of mass of each shape and to make
its principal inertia axis coincide with the canonical axis of coordinates.
Volumes are supposed to be homogeneous (we do not need
to calculate the real center of mass or inertia, just that of the binary
shape) and the inertia matrix is calculated and diagonalized. The
diagonalization change of basis is taken as the 3D rotation to be
applied to each voxel of the shape. Also the minimal enclosing parallelepiped
whose faces are parallel to the coordinate planes
(enclosing box) is calculated after the rotation. This will be used
to know the minimal box that encloses all the shapes which in turn
will be used to know the dimensions of the matrix which will hold
the result of the mean shape.