X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmOrientation.cxx;h=cdac91f811dc2bff968b2dbbae065db6e80dd39f;hb=8ee21bb4ee2c8ce94b32e7cf1c4506e03117e679;hp=6632d4c80b968ec2205592b9293f3c88a60d1187;hpb=69d2c65c131c9752b1d64aa9b21de29c3acfe62d;p=gdcm.git diff --git a/src/gdcmOrientation.cxx b/src/gdcmOrientation.cxx index 6632d4c8..cdac91f8 100644 --- a/src/gdcmOrientation.cxx +++ b/src/gdcmOrientation.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmOrientation.cxx,v $ Language: C++ - Date: $Date: 2005/07/24 02:34:42 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/09/05 08:25:01 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,6 +18,8 @@ #include "gdcmOrientation.h" #include "gdcmFile.h" +#include "gdcmDebug.h" +#include // for sqrt namespace gdcm { @@ -34,21 +36,20 @@ namespace gdcm * (Axial, Coronal, Sagital) of the image * \note Should be run on the first gdcm::File of a 'coherent' Serie * @return orientation code - * @return orientation code - * # 0 : Not Applicable (neither 0020,0037 Image Orientation Patient - * # nor 0020,0032Image Position found ) - * # 1 : Axial - * # -1 : Axial invert - * # 2 : Coronal - * # -2 : Coronal invert - * # 3 : Sagital - * # -3 : Sagital invert - * # 4 : Heart Axial - * # -4 : Heart Axial invert - * # 5 : Heart Coronal - * # -5 : Heart Coronal invert - * # 6 : Heart Sagital - * # -6 : Heart Sagital invert + * # 0 : Not Applicable (neither 0020,0037 Image Orientation Patient + * # nor 0020,0032 Image Position found) + * # 1 : Axial + * # -1 : Axial invert + * # 2 : Coronal + * # -2 : Coronal invert + * # 3 : Sagital + * # -3 : Sagital invert + * # 4 : Heart Axial + * # -4 : Heart Axial invert + * # 5 : Heart Coronal + * # -5 : Heart Coronal invert + * # 6 : Heart Sagital + * # -6 : Heart Sagital invert */ double Orientation::TypeOrientation( File *f ) { @@ -56,7 +57,8 @@ double Orientation::TypeOrientation( File *f ) bool succ = f->GetImageOrientationPatient( iop ); if ( !succ ) { - return 0.; + gdcmErrorMacro( "No Image Orientation (0020,0037) found in the file, cannot proceed." ) + return 0; } vector3D ori1; @@ -67,12 +69,12 @@ double Orientation::TypeOrientation( File *f ) // two perpendicular vectors describe one plane double dicPlane[6][2][3] = - { { {1, 0, 0 },{0, 1, 0 } }, // Axial - { {1, 0, 0 },{0, 0, -1 } }, // Coronal - { {0, 1, 0 },{0, 0, -1 } }, // Sagittal - { { 0.8, 0.5, 0.0 },{-0.1, 0.1 , -0.95 } }, // Axial - HEART - { { 0.8, 0.5, 0.0 },{-0.6674, 0.687, 0.1794} }, // Coronal - HEART - { {-0.1, 0.1, -0.95},{-0.6674, 0.687, 0.1794} } // Sagittal - HEART + { { {1, 0, 0 },{0, 1, 0 } }, // Axial + { {1, 0, 0 },{0, 0, -1 } }, // Coronal + { {0, 1, 0 },{0, 0, -1 } }, // Sagittal + { { 0.8, 0.5, 0.0 },{-0.1, 0.1 , -0.95 } }, // Axial - HEART + { { 0.8, 0.5, 0.0 },{-0.6674, 0.687, 0.1794} }, // Coronal - HEART + { {-0.1, 0.1, -0.95},{-0.6674, 0.687, 0.1794} } // Sagittal - HEART }; vector3D refA; @@ -97,21 +99,20 @@ double Orientation::TypeOrientation( File *f ) } return res.first; /* -// i=0 -// res=[0,99999] ## [ , ] -// for plane in dicPlane: -// i=i+1 -// refA=plane[0] -// refB=plane[1] -// res=self.VerfCriterion( i , self.CalculLikelyhood2Vec(refA,refB,ori1,ori2) , res ) -// res=self.VerfCriterion( -i , self.CalculLikelyhood2Vec(refB,refA,ori1,ori2) , res ) -// return res[0] +// i=0 +// res=[0,99999] ## [ , ] +// for plane in dicPlane: +// i=i+1 +// refA=plane[0] +// refB=plane[1] +// res=self.VerfCriterion( i , self.CalculLikelyhood2Vec(refA,refB,ori1,ori2) , res ) +// res=self.VerfCriterion( -i , self.CalculLikelyhood2Vec(refB,refA,ori1,ori2) , res ) +// return res[0] */ - } Res -Orientation::VerfCriterion(int typeCriterion, double criterionNew, Res const & in) +Orientation::VerfCriterion(int typeCriterion, double criterionNew, Res const &in) { Res res; double criterion = in.second; @@ -132,7 +133,7 @@ Orientation::VerfCriterion(int typeCriterion, double criterionNew, Res const & i return res; } -inline double square_dist(vector3D const &v1, vector3D const & v2) +inline double square_dist(vector3D const &v1, vector3D const &v2) { double res; res = (v1.x - v2.x)*(v1.x - v2.x) + @@ -158,8 +159,8 @@ inline double square_dist(vector3D const &v1, vector3D const & v2) //------------------------- Other : ------------------------------------- // The calculus is based with vectors normalice double -Orientation::CalculLikelyhood2Vec(vector3D const & refA, vector3D const & refB, - vector3D const & ori1, vector3D const & ori2 ) +Orientation::CalculLikelyhood2Vec(vector3D const &refA, vector3D const &refB, + vector3D const &ori1, vector3D const &ori2 ) { vector3D ori3 = ProductVectorial(ori1,ori2);