21 #include "SHCoefficientsRotateCLP.h" 26 main(
int argc,
char *argv[])
31 utlException(_InputFile==
"" || _OutputFile==
"",
"no input or no output!");
37 typedef itk::VectorImage<double, 3> ImageType;
38 ImageType::Pointer shImage, shRotatedImage;
40 itk::ReadImage<ImageType>(_InputFile, shImage);
44 RotateFilterType::Pointer rotateFilter = RotateFilterType::New();
46 utlException(_VectorFromTo.size()!=4 && _VectorFromTo.size()!=6,
"wrong size! _VectorFromTo.size()="<<_VectorFromTo.size());
47 RotateFilterType::VectorType vFrom(3), vTo(3);
48 if (_VectorFromTo.size()==6)
50 for (
int i = 0; i < 3; i += 1 )
51 vFrom[i] = _VectorFromTo[i];
52 for (
int i = 0; i < 3; i += 1 )
53 vTo[i] = _VectorFromTo[i+3];
54 vFrom /= vFrom.GetTwoNorm();
55 vTo /= vFrom.GetTwoNorm();
60 vFrom[1]=_VectorFromTo[0]*
M_PI/180.0, vFrom[2]=_VectorFromTo[1]*
M_PI/180.0;
61 vTo[1]=_VectorFromTo[2]*
M_PI/180.0, vTo[2]=_VectorFromTo[3]*
M_PI/180.0;
69 RotateFilterType::MatrixType rotationMatrix(3,3);
70 utl::RotationMatrixFromUnitNormVectors<RotateFilterType::VectorType, RotateFilterType::MatrixType >(vFrom, vTo, rotationMatrix);
73 rotateFilter->SetInput(shImage);
74 rotateFilter->SetRotationMatrix(rotationMatrix);
76 if (_NumberOfThreads>0)
77 rotateFilter->SetNumberOfThreads(_NumberOfThreads);
79 rotateFilter->Update();
81 std::cout << clock.GetMean() <<
"s elapsed" << std::endl;
83 shRotatedImage = rotateFilter->GetOutput();
85 itk::SaveImage<ImageType>(shRotatedImage, _OutputFile);
int main(int argc, char *argv[])
helper functions specifically used in dmritool
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
#define utlException(cond, expout)
void spherical2Cartesian(const T r, const T theta, const T phi, T &x, T &y, T &z)
Rotate SH coefficient to all input pixels.
void PrintUtlVector(const NDArray< T, 1 > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)