From: srit Date: Thu, 15 Jul 2010 12:13:24 +0000 (+0000) Subject: Added templated version of GetBackwardAffineMatrix for clitkAffineRegistration (sr... X-Git-Tag: v1.2.0~531 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=58074f0d36fda9b8a06d046438cefa36086c891b;p=clitk.git Added templated version of GetBackwardAffineMatrix for clitkAffineRegistration (sr+bharath) --- diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2dd0659..5434cd8 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -14,6 +14,7 @@ SET(clitkCommon_SRC clitkListOfPair.cxx clitkTimer.cxx clitkImageCommon.cxx + clitkTransformUtilities.cxx clitkIO.cxx clitkVoxImageIO.cxx clitkVoxImageIOFactory.cxx diff --git a/common/clitkTransformUtilities.cxx b/common/clitkTransformUtilities.cxx new file mode 100644 index 0000000..b551248 --- /dev/null +++ b/common/clitkTransformUtilities.cxx @@ -0,0 +1,40 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ + +#include "clitkTransformUtilities.h" + +namespace clitk +{ + +//-------------------------------------------------------------------- +template < > +itk::Matrix +GetBackwardAffineMatrix<2>(itk::Array transformParameters) +{ + return GetBackwardAffineMatrix2D(transformParameters); +} + +//-------------------------------------------------------------------- +template < > +itk::Matrix +GetBackwardAffineMatrix<3>(itk::Array transformParameters) +{ + return GetBackwardAffineMatrix3D(transformParameters); +} + +} diff --git a/common/clitkTransformUtilities.h b/common/clitkTransformUtilities.h index 7c4ebaa..47f92ce 100644 --- a/common/clitkTransformUtilities.h +++ b/common/clitkTransformUtilities.h @@ -15,6 +15,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ + #ifndef CLITKTRANSFORMUTILITIES_H #define CLITKTRANSFORMUTILITIES_H #include "itkMatrix.h" @@ -30,9 +31,12 @@ namespace clitk //Declarations //============================================================================ itk::Matrix GetForwardAffineMatrix2D(itk::Array transformParameters); - itk::Matrix GetBackwardAffineMatrix2D(itk::Array transformParameters); itk::Matrix GetForwardAffineMatrix3D(itk::Array transformParameters); + + itk::Matrix GetBackwardAffineMatrix2D(itk::Array transformParameters); itk::Matrix GetBackwardAffineMatrix3D(itk::Array transformParameters); + template itk::Matrix GetBackwardAffineMatrix(itk::Array transformParameters); + itk::Matrix GetRotationMatrix3D(itk::Array rotationParameters); itk::Point GetRotatedPoint3D(itk::Array rotationParameters, itk::Point input); itk::Matrix GetCenteredRotationMatrix3D(itk::Array rotationParameters,itk::Point centerOfRotation); @@ -77,25 +81,6 @@ namespace clitk return matrix; } - inline itk::Matrix GetBackwardAffineMatrix2D(itk::Array transformParameters) - { - itk::Matrix matrix; - //rotation part - matrix[0][0]=cos(transformParameters[0]); - matrix[0][1]=sin(transformParameters[0]); - matrix[1][0]=-sin(transformParameters[0]); - matrix[1][1]=cos(transformParameters[0]); - //translation part - matrix[0][2]=transformParameters[1]; - matrix[1][2]=transformParameters[2]; - //homogenize - matrix[2][0]=0.; - matrix[2][1]=0.; - matrix[2][2]=1.; - return matrix; - } - - inline itk::Matrix GetForwardAffineMatrix3D(itk::Array transformParameters) { itk::Matrix matrix; @@ -122,6 +107,25 @@ namespace clitk } + inline itk::Matrix GetBackwardAffineMatrix2D(itk::Array transformParameters) + { + itk::Matrix matrix; + //rotation part + matrix[0][0]=cos(transformParameters[0]); + matrix[0][1]=sin(transformParameters[0]); + matrix[1][0]=-sin(transformParameters[0]); + matrix[1][1]=cos(transformParameters[0]); + //translation part + matrix[0][2]=transformParameters[1]; + matrix[1][2]=transformParameters[2]; + //homogenize + matrix[2][0]=0.; + matrix[2][1]=0.; + matrix[2][2]=1.; + return matrix; + } + + inline itk::Matrix GetBackwardAffineMatrix3D(itk::Array transformParameters) { itk::Matrix matrix; @@ -147,6 +151,12 @@ namespace clitk return matrix; } + template + inline itk::Matrix + GetBackwardAffineMatrix(itk::Array transformParameters) + { + } + inline itk::Matrix GetRotationMatrix3D(itk::Array rotationParameters) { itk::Matrix matrix;