]> Creatis software - clitk.git/blob - itk/clitkSliceBySliceRelativePositionFilter.h
be31dfc0fab8a6a0c6bdfac458f5e93255999fdd
[clitk.git] / itk / clitkSliceBySliceRelativePositionFilter.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 CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_H
20 #define CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24 #include "clitkAddRelativePositionConstraintToLabelImageFilter.h"
25
26 namespace clitk {
27   
28   //--------------------------------------------------------------------
29   /*
30     Perform Relative Position filtering in a slice by slice manner. 
31   */
32   //--------------------------------------------------------------------
33   
34   template <class ImageType>
35   class ITK_EXPORT SliceBySliceRelativePositionFilter:
36     public AddRelativePositionConstraintToLabelImageFilter<ImageType>
37   {
38
39   public:
40     /** Standard class typedefs. */
41     typedef AddRelativePositionConstraintToLabelImageFilter<ImageType>   Superclass;
42     typedef SliceBySliceRelativePositionFilter              Self;
43     typedef itk::SmartPointer<Self>                         Pointer;
44     typedef itk::SmartPointer<const Self>                   ConstPointer;
45        
46     /** Method for creation through the object factory. */
47     itkNewMacro(Self);
48     
49     /** Run-time type information (and related methods). */
50     itkTypeMacro(SliceBySliceRelativePositionFilter, ImageToImageFilter);
51     FILTERBASE_INIT;
52
53     /** ImageDimension constants */
54     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
55     typedef itk::Image<float, ImageDimension> FloatImageType;
56
57     /** Some convenient typedefs. */
58     typedef typename ImageType::ConstPointer ImageConstPointer;
59     typedef typename ImageType::Pointer      ImagePointer;
60     typedef typename ImageType::RegionType   RegionType; 
61     typedef typename ImageType::PixelType    PixelType;
62     typedef typename ImageType::SpacingType  SpacingType;
63     typedef typename ImageType::SizeType     SizeType;
64     typedef itk::Image<PixelType, ImageDimension-1> SliceType;
65     typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
66     typedef typename RelPosFilterType::OrientationTypeEnumeration OrientationTypeEnumeration;
67     
68     /** Input : initial image and object */
69     void SetInput(const ImageType * image);
70     void SetInputObject(const ImageType * image);
71
72     // Options
73     void PrintOptions();
74     itkGetConstMacro(Direction, int);
75     itkSetMacro(Direction, int);
76
77     itkGetConstMacro(UniqueConnectedComponentBySlice, bool);
78     itkSetMacro(UniqueConnectedComponentBySlice, bool);
79     itkBooleanMacro(UniqueConnectedComponentBySlice);
80
81     itkGetConstMacro(IgnoreEmptySliceObjectFlag, bool);
82     itkSetMacro(IgnoreEmptySliceObjectFlag, bool);
83     itkBooleanMacro(IgnoreEmptySliceObjectFlag);
84
85     itkGetConstMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
86     itkSetMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
87     itkBooleanMacro(UseASingleObjectConnectedComponentBySliceFlag);
88
89   protected:
90     SliceBySliceRelativePositionFilter();
91     virtual ~SliceBySliceRelativePositionFilter() {}
92     
93     virtual void GenerateOutputInformation();
94     virtual void GenerateInputRequestedRegion();
95     virtual void GenerateData();
96
97     ImagePointer input;
98     ImagePointer object;
99     ImagePointer m_working_input;
100     ImagePointer m_working_object;
101     bool         m_UniqueConnectedComponentBySlice;
102     int          m_Direction;
103     bool         m_IgnoreEmptySliceObjectFlag;
104     bool         m_UseASingleObjectConnectedComponentBySliceFlag;
105
106   private:
107     SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
108     void operator=(const Self&); //purposely not implemented
109     
110   }; // end class
111   //--------------------------------------------------------------------
112
113 } // end namespace clitk
114 //--------------------------------------------------------------------
115
116 #ifndef ITK_MANUAL_INSTANTIATION
117 #include "clitkSliceBySliceRelativePositionFilter.txx"
118 #endif
119
120 #endif