itk::ImageIOBase::Pointer genericReader =
itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
if (!genericReader) {
- std::cerr << "Image file format unknown while reading " << filename << std::endl;
+ std::cerr << "Image file format unknown while reading file <" << filename << ">" << std::endl;
exit(0);
}
genericReader->SetFileName(filename.c_str());
for(unsigned int i=0; i< dim-1; i++)
os << inputOrigin[i] << "x";
os << inputOrigin[dim-1] << " ";
+ os << header->GetImageSizeInPixels() << " ";
} else {
os << "Dim = " << dim << "D" << std::endl;
os << "PixelType = " << pixelTypeName << std::endl;
======================================================================-====*/
#ifndef CLITKIMAGECOMMON_H
#define CLITKIMAGECOMMON_H
-/**
- -------------------------------------------------------------------
- * @file clitkImageCommon.h
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date 07 Sep 2007 11:30:10
-
- * @brief
-
- -------------------------------------------------------------------*/
// clitk
#include "clitkCommon.h"
std::map<typename MaskImageType::PixelType,
std::map<typename InputImageType::PixelType, double> > & mapOfLabelsAndWeights);
+ //--------------------------------------------------------------------
+ template<class ImageType1, class ImageType2>
+ bool HasSameSizeAndSpacing(typename ImageType1::ConstPointer A,
+ typename ImageType2::ConstPointer B);
+
+ template<class ImageType1, class ImageType2>
+ bool HasSameSizeAndSpacing(typename ImageType1::Pointer A,
+ typename ImageType2::Pointer B);
+
#include "clitkImageCommon.txx"
} // end namespace
}
//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
template<class ImageType>
void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose)
}
//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
template<class ImageType>
void writeImage(const ImageType* image, const std::string & filename, const bool verbose)
}
//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
template<class InputImageType, class MaskImageType>
void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input,
}
//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+template<class ImageType1, class ImageType2>
+bool HasSameSizeAndSpacing(typename ImageType1::ConstPointer A,
+ typename ImageType2::ConstPointer B)
+{
+ if (A->GetImageDimension() != B->GetImageDimension()) return false;
+ for(unsigned int i=0; i<A->GetImageDimension(); i++) {
+ if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false;
+ if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false;
+ }
+ return true;
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+template<class ImageType1, class ImageType2>
+bool HasSameSizeAndSpacing(typename ImageType1::Pointer A,
+ typename ImageType2::Pointer B)
+{
+ if (A->GetImageDimension() != B->GetImageDimension()) return false;
+ for(unsigned int i=0; i<A->GetImageDimension(); i++) {
+ if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false;
+ if (A->GetLargestPossibleRegion().GetSize()[i] != B->GetLargestPossibleRegion().GetSize()[i]) return false;
+ }
+ return true;
+}
+//--------------------------------------------------------------------
+
#endif /* end #define CLITKIMAGECOMMON_TXX */