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 AddAnglesInRad(double a, double b);
96 void AddAnglesInDeg(double a, double b);
97 double GetAngle1InRad(int i) { return m_Angle1[i]; }
98 double GetAngle2InRad(int i) { return m_Angle2[i]; }
99 int GetNumberOfAngles();
100 std::string GetOrientationTypeString(int i) { return m_OrientationTypeString[i]; }
101 std::vector<std::string> & GetOrientationTypeString() { return m_OrientationTypeString; }
103 itkGetConstMacro(IntermediateSpacingFlag, bool);
104 itkSetMacro(IntermediateSpacingFlag, bool);
105 itkBooleanMacro(IntermediateSpacingFlag);
107 itkGetConstMacro(IntermediateSpacing, double);
108 itkSetMacro(IntermediateSpacing, double);
110 itkGetConstMacro(FuzzyThreshold, double);
111 itkSetMacro(FuzzyThreshold, double);
113 itkGetConstMacro(BackgroundValue, PixelType);
114 itkSetMacro(BackgroundValue, PixelType);
116 itkGetConstMacro(ObjectBackgroundValue, PixelType);
117 itkSetMacro(ObjectBackgroundValue, PixelType);
119 itkGetConstMacro(AutoCropFlag, bool);
120 itkSetMacro(AutoCropFlag, bool);
121 itkBooleanMacro(AutoCropFlag);
123 itkGetConstMacro(InverseOrientationFlag, bool);
124 itkSetMacro(InverseOrientationFlag, bool);
125 itkBooleanMacro(InverseOrientationFlag);
127 itkGetConstMacro(RemoveObjectFlag, bool);
128 itkSetMacro(RemoveObjectFlag, bool);
129 itkBooleanMacro(RemoveObjectFlag);
131 itkGetConstMacro(CombineWithOrFlag, bool);
132 itkSetMacro(CombineWithOrFlag, bool);
133 itkBooleanMacro(CombineWithOrFlag);
135 itkGetConstMacro(FuzzyMapOnlyFlag, bool);
136 itkSetMacro(FuzzyMapOnlyFlag, bool);
137 itkBooleanMacro(FuzzyMapOnlyFlag);
139 typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; }
141 // I dont want to verify inputs information
142 virtual void VerifyInputInformation() { }
148 AddRelativePositionConstraintToLabelImageFilter();
149 virtual ~AddRelativePositionConstraintToLabelImageFilter() {}
151 std::vector<OrientationTypeEnumeration> m_OrientationType;
152 std::vector<std::string> m_OrientationTypeString;
153 double m_IntermediateSpacing;
154 double m_FuzzyThreshold;
155 PixelType m_BackgroundValue;
156 PixelType m_ObjectBackgroundValue;
157 std::vector<double> m_Angle1;
158 std::vector<double> m_Angle2;
159 bool m_IntermediateSpacingFlag;
161 bool m_InverseOrientationFlag;
162 bool m_RemoveObjectFlag;
163 bool m_CombineWithOrFlag;
164 bool m_FuzzyMapOnlyFlag;
166 virtual void GenerateOutputInformation();
167 virtual void GenerateInputRequestedRegion();
168 virtual void GenerateData();
170 typedef itk::PasteImageFilter<ImageType,ImageType> PasteFilterType;
171 typename ImageType::Pointer working_image;
172 typename ImageType::Pointer object_resampled;
173 typename FloatImageType::Pointer relPos;
174 typename FloatImageType::Pointer m_FuzzyMap;
179 AddRelativePositionConstraintToLabelImageFilter(const Self&); //purposely not implemented
180 void operator=(const Self&); //purposely not implemented
183 //--------------------------------------------------------------------
185 } // end namespace clitk
186 //--------------------------------------------------------------------
188 #ifndef ITK_MANUAL_INSTANTIATION
189 #include "clitkAddRelativePositionConstraintToLabelImageFilter.txx"