]> Creatis software - clitk.git/blob - common/clitkImageCommon.h
Initial revision
[clitk.git] / common / clitkImageCommon.h
1 #ifndef CLITKIMAGECOMMON_H
2 #define CLITKIMAGECOMMON_H
3
4 /**
5  -------------------------------------------------------------------
6  * @file   clitkImageCommon.h
7  * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
8  * @date   07 Sep 2007 11:30:10
9
10  * @brief  
11
12  -------------------------------------------------------------------*/
13
14 // clitk
15 #include "clitkCommon.h"
16
17 // itk
18 #include "itkImage.h"
19 #include "itkImageFileReader.h"
20 #include "itkImageSeriesReader.h"
21 #include "itkImageFileWriter.h"
22 #include "gdcmFile.h"
23 #include "gdcmFileHelper.h"
24
25
26 namespace clitk {
27   
28   //--------------------------------------------------------------------
29   // New Image creation (no allocation)
30   template<class PixelType>
31   typename itk::Image<PixelType,1>::Pointer NewImage1D(int size, double spacing=1.0);
32   template<class PixelType>
33   typename itk::Image<PixelType,2>::Pointer NewImage2D(int sx, int sy, double dx=1.0, double dy=1.0);
34   template<class PixelType>
35   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);
36   template<class PixelType>
37   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);
38
39   //--------------------------------------------------------------------
40   // New Image creation (with allocation)
41
42   //--------------------------------------------------------------------
43   // Read an Write image
44   // template<class ImageType>
45   //   typename ImageType::Pointer ReadImage(const std::string & filename, const bool verbose=false);
46   template<typename ImageType>
47   typename ImageType::Pointer readImage(const std::string & filename, const bool verbose=false);  
48   template<typename ImageType>
49   typename ImageType::Pointer readImage(const std::vector<std::string> & filenames, const bool verbose=false);
50   template<class ImageType>
51   void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose=false);
52 //   template<class ImageType>  
53 //   void writeConstImage(const typename ImageType::ConstPointer image, const std::string & filename, const bool verbose=false);
54   template<class ImageType>  
55   void writeImage(const ImageType* image, const std::string & filename, const bool verbose=false);
56
57   //--------------------------------------------------------------------
58   // Read/print image header
59   itk::ImageIOBase::Pointer readImageHeader(const std::string & filename);
60   void printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os, const int level=0);
61
62   //--------------------------------------------------------------------
63   // Determine pixetype and dimension of an image file
64   void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType);
65
66   //--------------------------------------------------------------------
67   // Determine pixetype, dimension and number of pixel components  of an image file
68   void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType, int & components);
69
70   //--------------------------------------------------------------------
71   // Read a dicom header  
72   gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false);
73
74   //--------------------------------------------------------------------
75   template<class ImageType>
76   int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, 
77                                        std::vector<typename ImageType::PixelType> & listOfIntensities);
78   template<class InputImageType, class MaskImageType>
79   void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, 
80                                    const typename MaskImageType::Pointer & mask,
81                                    const std::vector<typename MaskImageType::PixelType> & listOfIntensities, 
82                                    std::map<typename MaskImageType::PixelType, 
83                                    std::map<typename InputImageType::PixelType, double> > & mapOfLabelsAndWeights);
84
85 #include "clitkImageCommon.txx"
86
87 } // end namespace
88
89 #endif /* end #define CLITKIMAGECOMMON_H */
90