]> Creatis software - clitk.git/blob - itk/clitkExtractSliceFilter.h
commented affinetransf header
[clitk.git] / itk / clitkExtractSliceFilter.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
19 #ifndef CLITKEXTRACTSLICEFILTER_H
20 #define CLITKEXTRACTSLICEFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24
25 // itk
26 #include "itkPasteImageFilter.h"
27
28 // itk ENST
29 #include "RelativePositionPropImageFilter.h"
30
31 namespace clitk {
32   
33   //--------------------------------------------------------------------
34   /*
35     Let A be an initial label image.
36     Let B be a label image with an object. 
37     Let o be an orientation relatively to the B object (for example RightTo, AntTo, InferiorTo ...)
38
39     This filter removes (=set background) from A all points that are
40     not in the wanted o orientation. It uses downsampled version for
41     faster processing, and (try to) take into account discretization
42     problem. Uses [Bloch 1999].
43   */
44   //--------------------------------------------------------------------
45   
46   template <class ImageType>
47   class ITK_EXPORT ExtractSliceFilter:
48     public clitk::FilterBase, 
49     public itk::ImageToImageFilter<ImageType, 
50                                    std::vector<typename itk::Image<typename ImageType::PixelType, 
51                                                                    ImageType::ImageDimension-1>::Pointer> > 
52   {
53
54   public:
55     /** Standard class typedefs. */
56     typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
57     typedef ExtractSliceFilter                              Self;
58     typedef itk::SmartPointer<Self>                         Pointer;
59     typedef itk::SmartPointer<const Self>                   ConstPointer;
60        
61     /** Method for creation through the object factory. */
62     itkNewMacro(Self);
63     
64     /** Run-time type information (and related methods). */
65     itkTypeMacro(ExtractSliceFilter, ImageToImageFilter);
66     FILTERBASE_INIT;
67
68     /** Some convenient typedefs. */
69     typedef typename ImageType::ConstPointer ImageConstPointer;
70     typedef typename ImageType::Pointer      ImagePointer;
71     typedef typename ImageType::RegionType   RegionType; 
72     typedef typename ImageType::PixelType    PixelType;
73     typedef typename ImageType::SpacingType  SpacingType;
74     typedef typename ImageType::SizeType     SizeType;
75     
76     /** ImageDimension constants */
77     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
78
79     /** Slice image type **/
80     typedef itk::Image<PixelType, ImageDimension-1> SliceType;
81     typedef typename SliceType::Pointer             SliceTypePointer;
82
83     /** Input : initial image and object */
84     void SetInput(const ImageType * image);
85     
86     // Options
87     itkGetConstMacro(Direction, int);
88     itkSetMacro(Direction, int);
89
90   protected:
91     ExtractSliceFilter();
92     virtual ~ExtractSliceFilter() {}
93     
94     int m_Direction;
95
96     virtual void GenerateOutputInformation();
97     virtual void GenerateInputRequestedRegion();
98     virtual void GenerateData();
99
100     ImagePointer input;
101     ImagePointer object;
102     std::vector<SliceTypePointer> output;
103
104   private:
105     ExtractSliceFilter(const Self&); //purposely not implemented
106     void operator=(const Self&); //purposely not implemented
107     
108   }; // end class
109   //--------------------------------------------------------------------
110
111 } // end namespace clitk
112 //--------------------------------------------------------------------
113
114 #ifndef ITK_MANUAL_INSTANTIATION
115 #include "clitkExtractSliceFilter.txx"
116 #endif
117
118 #endif