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://oncora1.lyon.fnclcc.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"
26 #include <itkPasteImageFilter.h>
29 #include "RelativePositionPropImageFilter.h"
33 //--------------------------------------------------------------------
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 ...)
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].
44 //--------------------------------------------------------------------
46 template <class ImageType>
47 class ITK_EXPORT AddRelativePositionConstraintToLabelImageFilter:
48 public clitk::FilterBase,
49 public itk::ImageToImageFilter<ImageType, ImageType>
53 /** Standard class typedefs. */
54 typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
55 typedef AddRelativePositionConstraintToLabelImageFilter Self;
56 typedef itk::SmartPointer<Self> Pointer;
57 typedef itk::SmartPointer<const Self> ConstPointer;
59 /** Method for creation through the object factory. */
62 /** Run-time type information (and related methods). */
63 itkTypeMacro(AddRelativePositionConstraintToLabelImageFilter, ImageToImageFilter);
66 /** Some convenient typedefs. */
67 typedef typename ImageType::ConstPointer ImageConstPointer;
68 typedef typename ImageType::Pointer ImagePointer;
69 typedef typename ImageType::RegionType RegionType;
70 typedef typename ImageType::PixelType PixelType;
71 typedef typename ImageType::SpacingType SpacingType;
72 typedef typename ImageType::SizeType SizeType;
73 typedef typename ImageType::IndexType IndexType;
74 typedef typename ImageType::PointType PointType;
76 /** ImageDimension constants */
77 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
78 typedef itk::Image<float, ImageDimension> FloatImageType;
80 /** Orientation types */
81 typedef enum { RightTo = 0, LeftTo = 1,
82 AntTo = 2, PostTo = 3,
83 InfTo = 4, SupTo = 5, Angle = 6
84 } OrientationTypeEnumeration;
86 /** Input : initial image and object */
87 void SetInput(const ImageType * image);
88 void SetInputObject(const ImageType * image);
91 void SetOrientationType(OrientationTypeEnumeration orientation);
92 itkGetConstMacro(OrientationType, OrientationTypeEnumeration);
93 void SetOrientationTypeString(std::string s);
94 itkGetConstMacro(OrientationTypeString, std::string);
96 void SetAngle1(double a);
97 void SetAngle2(double a);
98 itkGetConstMacro(Angle1, double);
99 itkGetConstMacro(Angle2, double);
101 itkGetConstMacro(ResampleBeforeRelativePositionFilter, bool);
102 itkSetMacro(ResampleBeforeRelativePositionFilter, bool);
103 itkBooleanMacro(ResampleBeforeRelativePositionFilter);
105 itkGetConstMacro(IntermediateSpacing, double);
106 itkSetMacro(IntermediateSpacing, double);
108 itkGetConstMacro(FuzzyThreshold, double);
109 itkSetMacro(FuzzyThreshold, double);
111 itkGetConstMacro(BackgroundValue, PixelType);
112 itkSetMacro(BackgroundValue, PixelType);
114 itkGetConstMacro(ObjectBackgroundValue, PixelType);
115 itkSetMacro(ObjectBackgroundValue, PixelType);
117 itkGetConstMacro(AutoCropFlag, bool);
118 itkSetMacro(AutoCropFlag, bool);
119 itkBooleanMacro(AutoCropFlag);
121 itkGetConstMacro(NotFlag, bool);
122 itkSetMacro(NotFlag, bool);
123 itkBooleanMacro(NotFlag);
126 AddRelativePositionConstraintToLabelImageFilter();
127 virtual ~AddRelativePositionConstraintToLabelImageFilter() {}
129 OrientationTypeEnumeration m_OrientationType;
130 std::string m_OrientationTypeString;
131 double m_IntermediateSpacing;
132 double m_FuzzyThreshold;
133 PixelType m_BackgroundValue;
134 PixelType m_ObjectBackgroundValue;
137 bool m_ResampleBeforeRelativePositionFilter;
141 virtual void GenerateOutputInformation();
142 virtual void GenerateInputRequestedRegion();
143 virtual void GenerateData();
145 typedef itk::PasteImageFilter<ImageType,ImageType> PadFilterType;
146 typename ImageType::Pointer working_image;
147 typename ImageType::Pointer object_resampled;
148 typename FloatImageType::Pointer relPos;
153 AddRelativePositionConstraintToLabelImageFilter(const Self&); //purposely not implemented
154 void operator=(const Self&); //purposely not implemented
157 //--------------------------------------------------------------------
159 } // end namespace clitk
160 //--------------------------------------------------------------------
162 #ifndef ITK_MANUAL_INSTANTIATION
163 #include "clitkAddRelativePositionConstraintToLabelImageFilter.txx"