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
21 -------------------------------------------------------------------
22 * @file clitkImageCommon.h
23 * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
24 * @date 07 Sep 2007 11:30:10
28 -------------------------------------------------------------------*/
31 #include "clitkCommon.h"
35 #include "itkImageFileReader.h"
36 #include "itkImageSeriesReader.h"
37 #include "itkImageFileWriter.h"
39 #include "gdcmFileHelper.h"
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);
55 template<class ImageType>
56 typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate=true);
58 template<class ImageType>
59 void CopyValues(const typename ImageType::Pointer input, typename ImageType::Pointer output);
60 //--------------------------------------------------------------------
61 // New Image creation (with allocation)
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);
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);
83 //--------------------------------------------------------------------
84 // Determine pixetype and dimension of an image file
85 void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType);
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);
91 //--------------------------------------------------------------------
92 // Read a dicom header
93 gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false);
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);
106 #include "clitkImageCommon.txx"
110 #endif /* end #define CLITKIMAGECOMMON_H */