35 #ifndef AIMS_TALAIRACH_TALBOX_H
36 #define AIMS_TALAIRACH_TALBOX_H
58 template<
class T >
inline
62 int x, y, z, dx = d->getSizeX(), dy = d->getSizeY(), dz = d->getSizeZ();
64 Point3df boxmax( -10000.0f, -10000.0f, -10000.0f );
65 Point3df boxmin( 10000.0f, 10000.0f, 10000.0f );
68 for ( z=0; z<dz; z++ )
69 for ( y=0; y<dy; y++ )
70 for ( x=0; x<dx; x++ )
71 if ( d->at( x, y, z ) )
73 pt =
Point3df(
float( x ),
float( y ),
float( z ) );
74 pt[ 0 ] *= dsize[ 0 ];
75 pt[ 1 ] *= dsize[ 1 ];
76 pt[ 2 ] *= dsize[ 2 ];
79 if ( npt[ 0 ] < boxmin[ 0 ] ) boxmin[ 0 ] = npt[ 0 ];
80 if ( npt[ 1 ] < boxmin[ 1 ] ) boxmin[ 1 ] = npt[ 1 ];
81 if ( npt[ 2 ] < boxmin[ 2 ] ) boxmin[ 2 ] = npt[ 2 ];
82 if ( npt[ 0 ] > boxmax[ 0 ] ) boxmax[ 0 ] = npt[ 0 ];
83 if ( npt[ 1 ] > boxmax[ 1 ] ) boxmax[ 1 ] = npt[ 1 ];
84 if ( npt[ 2 ] > boxmax[ 2 ] ) boxmax[ 2 ] = npt[ 2 ];
87 if ( fabs( boxmin[ 0 ] ) > fabs( boxmax[ 0 ] ) )
88 _scale[ 0 ] = 1.0f / fabs( boxmin[ 0 ] );
89 else _scale[ 0 ] = 1.0f / fabs( boxmax[ 0 ] );
91 std::cout <<
"Box Min : " << boxmin <<
"\tBox Max :" << boxmax << std::endl ;
92 _scale[ 1 ] = 1.0f / fabs( boxmax[ 1 ] );
95 _scale[ 2 ] = 1.0f / fabs( boxmin[ 2 ] );
99 template<
class T >
inline
103 computeTransformation( pt );
109 rotation(0, 0) = -_crossVec[ 0 ];
110 rotation(0, 1) = -_crossVec[ 1 ];
111 rotation(0, 2) = -_crossVec[ 2 ];
113 rotation(1, 0) = _ACPCVec[ 0 ];
114 rotation(1, 1) = _ACPCVec[ 1 ];
115 rotation(1, 2) = _ACPCVec[ 2 ];
117 rotation(2, 0) = _hemiVec[ 0 ];
118 rotation(2, 1) = _hemiVec[ 1 ];
119 rotation(2, 2) = _hemiVec[ 2 ];
121 _transformation.setTranslation(
Point3df(0., 0., 0.) );
122 _transformation.setMatrix(rotation);
124 std::cout <<
"Scale : " << _scale << std::endl ;
125 _transformation.scale(
Point3df(1., 1., 1. ),
126 Point3df(1.0f/_scale[0], 1.0f/_scale[1], 1.0f/_scale[2] ) ) ;
127 _transformation.setTranslation( _transformation.transform(translation) );
128 return _transformation ;
void computeBox(const carto::rc_ptr< carto::Volume< T > > &)
aims::AffineTransformation3d computeTransformationAndBox(const TalairachPoints &, const carto::rc_ptr< carto::Volume< T > > &)
Point3df toTalairach(const Point3df &)