1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKIMAGECOMMON_H
19 #define CLITKIMAGECOMMON_H
22 #include "clitkCommon.h"
26 #include "itkImageFileReader.h"
27 #include "itkImageSeriesReader.h"
28 #include "itkImageFileWriter.h"
29 //#include "gdcmFile.h"
30 //#include "gdcmFileHelper.h"
35 //--------------------------------------------------------------------
36 // New Image creation (no allocation)
37 template<class PixelType>
38 typename itk::Image<PixelType,1>::Pointer NewImage1D(int size, double spacing=1.0);
39 template<class PixelType>
40 typename itk::Image<PixelType,2>::Pointer NewImage2D(int sx, int sy, double dx=1.0, double dy=1.0);
41 template<class PixelType>
42 typename itk::Image<PixelType,3>::Pointer NewImage3D(int sx, int sy, int sz, double dx=1.0, double dy=1.0, double dz=1.0);
43 template<class PixelType>
44 typename itk::Image<PixelType,4>::Pointer NewImage4D(int sx, int sy, int sz, int st, double dx=1.0, double dy=1.0, double dz=1.0, double dt=1.0);
46 template<class ImageType>
47 typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate=true);
49 template<class ImageType>
50 void CopyValues(const typename ImageType::Pointer input, typename ImageType::Pointer output);
51 //--------------------------------------------------------------------
52 // New Image creation (with allocation)
54 //--------------------------------------------------------------------
55 // Read an Write image
56 // template<class ImageType>
57 // typename ImageType::Pointer ReadImage(const std::string & filename, const bool verbose=false);
58 template<typename ImageType>
59 typename ImageType::Pointer readImage(const std::string & filename, const bool verbose=false);
60 template<typename ImageType>
61 typename ImageType::Pointer readImage(const std::vector<std::string> & filenames, const bool verbose=false);
62 template<class ImageType>
63 void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose=false);
64 // template<class ImageType>
65 // void writeConstImage(const typename ImageType::ConstPointer image, const std::string & filename, const bool verbose=false);
66 template<class ImageType>
67 void writeImage(const ImageType* image, const std::string & filename, const bool verbose=false);
69 //--------------------------------------------------------------------
70 // Read/print image header
71 itk::ImageIOBase::Pointer readImageHeader(const std::string & filename,bool exit_on_error=true);
72 void printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os, const int level=0);
74 //--------------------------------------------------------------------
75 // Determine pixetype and dimension of an image file
76 void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType);
78 //--------------------------------------------------------------------
79 // Determine pixetype, dimension and number of pixel components of an image file
80 void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType, int & components);
82 //--------------------------------------------------------------------
83 // Read a dicom header
84 // gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false);
86 //--------------------------------------------------------------------
87 template<class ImageType>
88 int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image,
89 std::vector<typename ImageType::PixelType> & listOfIntensities);
90 template<class InputImageType, class MaskImageType>
91 void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input,
92 const typename MaskImageType::Pointer & mask,
93 const std::vector<typename MaskImageType::PixelType> & listOfIntensities,
94 std::map<typename MaskImageType::PixelType,
95 std::map<typename InputImageType::PixelType, double> > & mapOfLabelsAndWeights);
97 //--------------------------------------------------------------------
98 template<class ImageType1, class ImageType2>
99 bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A,
100 typename ImageType2::ConstPointer B);
102 template<class ImageType1, class ImageType2>
103 bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A,
104 typename ImageType2::Pointer B);
106 //--------------------------------------------------------------------
107 template<class ImageType1, class ImageType2>
108 bool HaveSameSpacing(typename ImageType1::ConstPointer A,
109 typename ImageType2::ConstPointer B);
111 template<class ImageType1, class ImageType2>
112 bool HaveSameSpacing(typename ImageType1::Pointer A,
113 typename ImageType2::Pointer B);
115 #include "clitkImageCommon.txx"
119 #endif /* end #define CLITKIMAGECOMMON_H */