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