]> Creatis software - clitk.git/blob - tools/clitkSplitImageGenericFilter.h
Add clitkImage2Dicom tool
[clitk.git] / tools / clitkSplitImageGenericFilter.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://www.centreleonberard.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 clitkSplitImageGenericFilter_H
19 #define clitkSplitImageGenericFilter_H
20 /**
21  -------------------------------------------------------------------
22  * @file   clitkSplitImageGenericFilter.h
23  * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
24  * @date   23 Feb 2008
25  -------------------------------------------------------------------*/
26
27 // clitk include
28 #include "clitkIO.h"
29 #include "clitkCommon.h"
30 #include "clitkImageCommon.h"
31 #include "clitkImageToImageGenericFilter.h"
32
33 // itk include
34 #include "itkImage.h"
35 #include "itkImageIOBase.h"
36 #include "itkImageRegionIterator.h"
37 #include "itkImageRegionConstIterator.h"
38
39 namespace clitk {
40   
41   //--------------------------------------------------------------------
42   class SplitImageGenericFilter: 
43     public clitk::ImageToImageGenericFilter<SplitImageGenericFilter> {
44   
45   public:
46         
47     // Constructor 
48     SplitImageGenericFilter ();
49
50     // Types
51     typedef SplitImageGenericFilter       Self;
52     typedef itk::SmartPointer<Self>       Pointer;
53     typedef itk::SmartPointer<const Self> ConstPointer;
54
55     // New
56     itkNewMacro(Self);
57     
58     // Set methods
59     void SetSplitDimension (int dim) { mSplitDimension = dim; }
60     void SetVerbose (const bool v) { m_Verbose = v; }
61     void SetPng (const bool v) { m_Png = v; }
62     void SetWindowLevel(const double w, const double l){ m_Window = w; m_Level = l;}
63
64    //--------------------------------------------------------------------
65     // Main function called each time the filter is updated
66     template<class InputImageType>  
67     void UpdateWithInputImageType();
68
69   protected:  
70     template <class ImageType>
71     class PngConversion
72     {
73     public:
74       typedef typename ImageType::Pointer ImagePointer;
75       typedef itk::Image< unsigned char, ImageType::ImageDimension > OutputPngImageType;
76       typedef typename OutputPngImageType::Pointer OutputPngImagePointer;
77       OutputPngImagePointer Do(double window, double level, ImagePointer input);
78     private:
79       template<unsigned int> struct PixelDimType {};
80       template<unsigned int Dim> OutputPngImagePointer Do(double window,
81                                                           double level,
82                                                           ImagePointer input,
83                                                           PixelDimType<Dim> *);
84       OutputPngImagePointer Do(double window, double level, ImagePointer input, PixelDimType<1> *);
85     };
86
87     template<unsigned int Dim> void InitializeImageType();
88     int  mSplitDimension;
89     bool m_Verbose;
90     bool m_Png;
91     double m_Window, m_Level;
92
93   }; // end class SplitImageGenericFilter
94 //--------------------------------------------------------------------
95
96 } // end namespace
97 //--------------------------------------------------------------------
98
99 #endif //#define clitkSplitImageGenericFilter_H
100