X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageCommon.txx;h=5aa3b2eba55e44db3e973328c370b05935f95cab;hb=1e17c9ce74f96c9ea76468925ebdbaaed53325ba;hp=9d8d6e131b62c47bdedd20b599a0b77f8ba56f46;hpb=573d80d0f7a17607d2ee883c21c940c0ba020282;p=clitk.git diff --git a/common/clitkImageCommon.txx b/common/clitkImageCommon.txx index 9d8d6e1..5aa3b2e 100644 --- a/common/clitkImageCommon.txx +++ b/common/clitkImageCommon.txx @@ -21,7 +21,7 @@ //-------------------------------------------------------------------- template -typename itk::Image::Pointer +typename itk::Image::Pointer NewImage1D(int vsize, double vspacing) { typedef itk::Image ImageType; @@ -40,7 +40,7 @@ NewImage1D(int vsize, double vspacing) //-------------------------------------------------------------------- template -typename itk::Image::Pointer +typename itk::Image::Pointer NewImage2D(int sx, int sy, double dx, double dy) { typedef itk::Image ImageType; @@ -62,7 +62,7 @@ NewImage2D(int sx, int sy, double dx, double dy) //-------------------------------------------------------------------- template -typename itk::Image::Pointer +typename itk::Image::Pointer NewImage3D(int sx, int sy, int sz, double dx, double dy, double dz) { typedef itk::Image ImageType; @@ -323,13 +323,12 @@ void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, //-------------------------------------------------------------------- template -bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A, - typename ImageType2::ConstPointer B) +bool HaveSameSpacing(typename ImageType1::ConstPointer A, + typename ImageType2::ConstPointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; for(unsigned int i=0; iGetImageDimension(); i++) { if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; - if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false; } return true; } @@ -337,13 +336,12 @@ bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A, //-------------------------------------------------------------------- template -bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A, - typename ImageType2::Pointer B) +bool HaveSameSpacing(typename ImageType1::Pointer A, + typename ImageType2::Pointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; for(unsigned int i=0; iGetImageDimension(); i++) { if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; - if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false; } return true; } @@ -351,12 +349,12 @@ bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A, //-------------------------------------------------------------------- template -bool HaveSameSpacing(typename ImageType1::ConstPointer A, - typename ImageType2::ConstPointer B) +bool HaveSameSize(typename ImageType1::ConstPointer A, + typename ImageType2::ConstPointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; for(unsigned int i=0; iGetImageDimension(); i++) { - if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; + if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false; } return true; } @@ -364,16 +362,36 @@ bool HaveSameSpacing(typename ImageType1::ConstPointer A, //-------------------------------------------------------------------- template -bool HaveSameSpacing(typename ImageType1::Pointer A, - typename ImageType2::Pointer B) +bool HaveSameSize(typename ImageType1::Pointer A, + typename ImageType2::Pointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; for(unsigned int i=0; iGetImageDimension(); i++) { - if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; + if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false; } return true; } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A, + typename ImageType2::ConstPointer B) +{ + return ( HaveSameSize(A, B) && + HaveSameSpacing(A, B) ); +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A, + typename ImageType2::Pointer B) +{ + return ( HaveSameSize(A, B) && + HaveSameSpacing(A, B) ); +} +//-------------------------------------------------------------------- + #endif /* end #define CLITKIMAGECOMMON_TXX */