]> Creatis software - clitk.git/blob - common/clitkImageCommon.h
Cleared CMake files, removed LINK_LIBRARIES (deprecated) and prepared for packaging...
[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   template<class ImageType>
56   typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate=true);
57
58   template<class ImageType>
59   void CopyValues(const typename ImageType::Pointer input, typename ImageType::Pointer output);
60   //--------------------------------------------------------------------
61   // New Image creation (with allocation)
62
63   //--------------------------------------------------------------------
64   // Read an Write image
65   // template<class ImageType>
66   //   typename ImageType::Pointer ReadImage(const std::string & filename, const bool verbose=false);
67   template<typename ImageType>
68   typename ImageType::Pointer readImage(const std::string & filename, const bool verbose=false);  
69   template<typename ImageType>
70   typename ImageType::Pointer readImage(const std::vector<std::string> & filenames, const bool verbose=false);
71   template<class ImageType>
72   void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose=false);
73 //   template<class ImageType>  
74 //   void writeConstImage(const typename ImageType::ConstPointer image, const std::string & filename, const bool verbose=false);
75   template<class ImageType>  
76   void writeImage(const ImageType* image, const std::string & filename, const bool verbose=false);
77
78   //--------------------------------------------------------------------
79   // Read/print image header
80   itk::ImageIOBase::Pointer readImageHeader(const std::string & filename,bool exit_on_error=true);
81   void printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os, const int level=0);
82
83   //--------------------------------------------------------------------
84   // Determine pixetype and dimension of an image file
85   void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType);
86
87   //--------------------------------------------------------------------
88   // Determine pixetype, dimension and number of pixel components  of an image file
89   void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType, int & components);
90
91   //--------------------------------------------------------------------
92   // Read a dicom header  
93   gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false);
94
95   //--------------------------------------------------------------------
96   template<class ImageType>
97   int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, 
98                                        std::vector<typename ImageType::PixelType> & listOfIntensities);
99   template<class InputImageType, class MaskImageType>
100   void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, 
101                                    const typename MaskImageType::Pointer & mask,
102                                    const std::vector<typename MaskImageType::PixelType> & listOfIntensities, 
103                                    std::map<typename MaskImageType::PixelType, 
104                                    std::map<typename InputImageType::PixelType, double> > & mapOfLabelsAndWeights);
105
106 #include "clitkImageCommon.txx"
107
108 } // end namespace
109
110 #endif /* end #define CLITKIMAGECOMMON_H */
111