]> Creatis software - clitk.git/blob - itk/clitkSliceBySliceRelativePositionFilter.h
add autocrop and options
[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 clitk::FilterBase, 
37     public itk::ImageToImageFilter<ImageType, ImageType> 
38   {
39
40   public:
41     /** Standard class typedefs. */
42     typedef itk::ImageToImageFilter<ImageType, ImageType>   Superclass;
43     typedef SliceBySliceRelativePositionFilter              Self;
44     typedef itk::SmartPointer<Self>                         Pointer;
45     typedef itk::SmartPointer<const Self>                   ConstPointer;
46        
47     /** Method for creation through the object factory. */
48     itkNewMacro(Self);
49     
50     /** Run-time type information (and related methods). */
51     itkTypeMacro(SliceBySliceRelativePositionFilter, ImageToImageFilter);
52     FILTERBASE_INIT;
53
54     /** ImageDimension constants */
55     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
56     typedef itk::Image<float, ImageDimension> FloatImageType;
57
58     /** Some convenient typedefs. */
59     typedef typename ImageType::ConstPointer ImageConstPointer;
60     typedef typename ImageType::Pointer      ImagePointer;
61     typedef typename ImageType::RegionType   RegionType; 
62     typedef typename ImageType::PixelType    PixelType;
63     typedef typename ImageType::SpacingType  SpacingType;
64     typedef typename ImageType::SizeType     SizeType;
65     typedef itk::Image<PixelType, ImageDimension-1> SliceType;
66     typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;
67     typedef typename RelPosFilterType::OrientationTypeEnumeration OrientationTypeEnumeration;
68     
69     /** Input : initial image and object */
70     void SetInput(const ImageType * image);
71     void SetInputObject(const ImageType * image);
72     
73     // Options
74     itkGetConstMacro(Direction, int);
75     itkSetMacro(Direction, int);
76     itkGetConstMacro(ObjectBackgroundValue, PixelType);
77     itkSetMacro(ObjectBackgroundValue, PixelType);
78
79     itkSetMacro(OrientationTypeString, std::string);
80     itkGetConstMacro(OrientationTypeString, std::string);
81
82     itkGetConstMacro(ResampleBeforeRelativePositionFilter, bool);
83     itkSetMacro(ResampleBeforeRelativePositionFilter, bool);
84     itkBooleanMacro(ResampleBeforeRelativePositionFilter);
85
86     itkGetConstMacro(IntermediateSpacing, double);
87     itkSetMacro(IntermediateSpacing, double);
88
89     itkGetConstMacro(FuzzyThreshold, double);
90     itkSetMacro(FuzzyThreshold, double);
91
92     itkGetConstMacro(UniqueConnectedComponentBySlice, bool);
93     itkSetMacro(UniqueConnectedComponentBySlice, bool);
94     itkBooleanMacro(UniqueConnectedComponentBySlice);
95
96     itkGetConstMacro(AutoCropFlag, bool);
97     itkSetMacro(AutoCropFlag, bool);
98     itkBooleanMacro(AutoCropFlag);
99
100     itkGetConstMacro(NotFlag, bool);
101     itkSetMacro(NotFlag, bool);
102     itkBooleanMacro(NotFlag);
103
104   protected:
105     SliceBySliceRelativePositionFilter();
106     virtual ~SliceBySliceRelativePositionFilter() {}
107     
108     int m_Direction;
109     PixelType m_ObjectBackgroundValue;
110     // OrientationTypeEnumeration m_OrientationType;
111     std::string m_OrientationTypeString;
112     double m_IntermediateSpacing;
113     double m_FuzzyThreshold;
114     bool m_ResampleBeforeRelativePositionFilter;
115
116     virtual void GenerateOutputInformation();
117     virtual void GenerateInputRequestedRegion();
118     virtual void GenerateData();
119
120     ImagePointer input;
121     ImagePointer object;
122     ImagePointer m_working_input;
123     ImagePointer m_working_object;
124     bool m_UniqueConnectedComponentBySlice;
125     bool m_NotFlag;
126     bool m_AutoCropFlag;
127
128   private:
129     SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
130     void operator=(const Self&); //purposely not implemented
131     
132   }; // end class
133   //--------------------------------------------------------------------
134
135 } // end namespace clitk
136 //--------------------------------------------------------------------
137
138 #ifndef ITK_MANUAL_INSTANTIATION
139 #include "clitkSliceBySliceRelativePositionFilter.txx"
140 #endif
141
142 #endif