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://www.centreleonberard.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 ===========================================================================**/
19 #ifndef CLITKADDRELATIVEPOSITIONCONSTRAINTTOLABELIMAGEFILTER_H
20 #define CLITKADDRELATIVEPOSITIONCONSTRAINTTOLABELIMAGEFILTER_H
23 #include "clitkFilterBase.h"
24 #include "clitkCropLikeImageFilter.h"
27 #include <itkPasteImageFilter.h>
30 #include "RelativePositionPropImageFilter.h"
34 //--------------------------------------------------------------------
36 Let A be an initial label image.
37 Let B be a label image with an object.
38 Let o be an orientation relatively to the B object (for example RightTo, AntTo, InferiorTo ...)
40 This filter removes (=set background) from A all points that are
41 not in the wanted o orientation. It uses downsampled version for
42 faster processing, and (try to) take into account discretization
43 problem. Uses [Bloch 1999].
45 //--------------------------------------------------------------------
47 template <class ImageType>
48 class ITK_EXPORT AddRelativePositionConstraintToLabelImageFilter:
49 public clitk::FilterBase,
50 public itk::ImageToImageFilter<ImageType, ImageType>
54 /** Standard class typedefs. */
55 typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
56 typedef AddRelativePositionConstraintToLabelImageFilter Self;
57 typedef itk::SmartPointer<Self> Pointer;
58 typedef itk::SmartPointer<const Self> ConstPointer;
60 /** Method for creation through the object factory. */
63 /** Run-time type information (and related methods). */
64 itkTypeMacro(AddRelativePositionConstraintToLabelImageFilter, ImageToImageFilter);
67 /** Some convenient typedefs. */
68 typedef typename ImageType::ConstPointer ImageConstPointer;
69 typedef typename ImageType::Pointer ImagePointer;
70 typedef typename ImageType::RegionType RegionType;
71 typedef typename ImageType::PixelType PixelType;
72 typedef typename ImageType::SpacingType SpacingType;
73 typedef typename ImageType::SizeType SizeType;
74 typedef typename ImageType::IndexType IndexType;
75 typedef typename ImageType::PointType PointType;
77 /** ImageDimension constants */
78 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
79 typedef itk::Image<float, ImageDimension> FloatImageType;
81 /** Orientation types */
82 typedef enum { RightTo = 0, LeftTo = 1,
83 AntTo = 2, PostTo = 3,
84 InfTo = 4, SupTo = 5, Angle = 6
85 } OrientationTypeEnumeration;
87 /** Input : initial image and object */
88 void SetInput(const ImageType * image);
89 void SetInputObject(const ImageType * image);
92 void AddOrientationType(OrientationTypeEnumeration orientation);
93 void AddOrientationTypeString(std::string s);
94 void ClearOrientationType();
95 void AddAngles(double a, double b);
96 double GetAngle1(int i) { return m_Angle1[i]; }
97 double GetAngle2(int i) { return m_Angle2[i]; }
98 int GetNumberOfAngles();
99 std::string GetOrientationTypeString(int i) { return m_OrientationTypeString[i]; }
100 std::vector<std::string> & GetOrientationTypeString() { return m_OrientationTypeString; }
102 itkGetConstMacro(IntermediateSpacingFlag, bool);
103 itkSetMacro(IntermediateSpacingFlag, bool);
104 itkBooleanMacro(IntermediateSpacingFlag);
106 itkGetConstMacro(IntermediateSpacing, double);
107 itkSetMacro(IntermediateSpacing, double);
109 itkGetConstMacro(FuzzyThreshold, double);
110 itkSetMacro(FuzzyThreshold, double);
112 itkGetConstMacro(BackgroundValue, PixelType);
113 itkSetMacro(BackgroundValue, PixelType);
115 itkGetConstMacro(ObjectBackgroundValue, PixelType);
116 itkSetMacro(ObjectBackgroundValue, PixelType);
118 itkGetConstMacro(AutoCropFlag, bool);
119 itkSetMacro(AutoCropFlag, bool);
120 itkBooleanMacro(AutoCropFlag);
122 itkGetConstMacro(InverseOrientationFlag, bool);
123 itkSetMacro(InverseOrientationFlag, bool);
124 itkBooleanMacro(InverseOrientationFlag);
126 itkGetConstMacro(RemoveObjectFlag, bool);
127 itkSetMacro(RemoveObjectFlag, bool);
128 itkBooleanMacro(RemoveObjectFlag);
130 itkGetConstMacro(CombineWithOrFlag, bool);
131 itkSetMacro(CombineWithOrFlag, bool);
132 itkBooleanMacro(CombineWithOrFlag);
134 itkGetConstMacro(FuzzyMapOnlyFlag, bool);
135 itkSetMacro(FuzzyMapOnlyFlag, bool);
136 itkBooleanMacro(FuzzyMapOnlyFlag);
138 typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; }
140 // I dont want to verify inputs information
141 virtual void VerifyInputInformation() { }
147 AddRelativePositionConstraintToLabelImageFilter();
148 virtual ~AddRelativePositionConstraintToLabelImageFilter() {}
150 std::vector<OrientationTypeEnumeration> m_OrientationType;
151 std::vector<std::string> m_OrientationTypeString;
152 double m_IntermediateSpacing;
153 double m_FuzzyThreshold;
154 PixelType m_BackgroundValue;
155 PixelType m_ObjectBackgroundValue;
156 std::vector<double> m_Angle1;
157 std::vector<double> m_Angle2;
158 bool m_IntermediateSpacingFlag;
160 bool m_InverseOrientationFlag;
161 bool m_RemoveObjectFlag;
162 bool m_CombineWithOrFlag;
163 bool m_FuzzyMapOnlyFlag;
165 virtual void GenerateOutputInformation();
166 virtual void GenerateInputRequestedRegion();
167 virtual void GenerateData();
169 typedef itk::PasteImageFilter<ImageType,ImageType> PasteFilterType;
170 typename ImageType::Pointer working_image;
171 typename ImageType::Pointer object_resampled;
172 typename FloatImageType::Pointer relPos;
173 typename FloatImageType::Pointer m_FuzzyMap;
178 AddRelativePositionConstraintToLabelImageFilter(const Self&); //purposely not implemented
179 void operator=(const Self&); //purposely not implemented
182 //--------------------------------------------------------------------
184 } // end namespace clitk
185 //--------------------------------------------------------------------
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "clitkAddRelativePositionConstraintToLabelImageFilter.txx"