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 CLITKRELATIVEPOSITIONANALYZERFILTER_H
20 #define CLITKRELATIVEPOSITIONANALYZERFILTER_H
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24 #include "clitkFilterBase.h"
25 #include "clitkSliceBySliceRelativePositionFilter.h"
26 #include "clitkRelativePositionDataBase.h"
29 #include <itkImageToImageFilter.h>
30 #include <itkLabelStatisticsImageFilter.h>
34 //--------------------------------------------------------------------
36 Analyze the relative position of a Target (mask image) according
37 to some Object (mask image), in a given Support (mask
38 image). Compute the optimal threshold allowing to remove the
39 maximal area from the Support without removing area belonging to
42 //--------------------------------------------------------------------
44 template <class ImageType>
45 class RelativePositionAnalyzerFilter:
46 // public virtual clitk::FilterBase,
47 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
48 public itk::ImageToImageFilter<ImageType, ImageType>
52 /** Standard class typedefs. */
53 typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
54 typedef RelativePositionAnalyzerFilter<ImageType> Self;
55 typedef itk::SmartPointer<Self> Pointer;
56 typedef itk::SmartPointer<const Self> ConstPointer;
58 /** Method for creation through the object factory. */
61 /** Run-time type information (and related methods). */
62 itkTypeMacro(RelativePositionAnalyzerFilter, ImageToImageFilter);
64 /** Some convenient typedefs. */
65 typedef typename ImageType::ConstPointer ImageConstPointer;
66 typedef typename ImageType::Pointer ImagePointer;
67 typedef typename ImageType::RegionType RegionType;
68 typedef typename ImageType::PixelType PixelType;
69 typedef typename ImageType::SpacingType SpacingType;
70 typedef typename ImageType::SizeType SizeType;
71 typedef typename ImageType::IndexType IndexType;
72 typedef typename ImageType::PointType PointType;
74 /** ImageDimension constants */
75 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
77 typedef itk::Image<float, ImageDimension> FloatImageType;
79 /** Input : initial image and object */
80 void SetInputSupport(const ImageType * image);
81 void SetInputObject(const ImageType * image);
82 void SetInputTarget(const ImageType * image);
85 itkGetConstMacro(BackgroundValue, PixelType);
86 itkSetMacro(BackgroundValue, PixelType);
88 itkGetConstMacro(ForegroundValue, PixelType);
89 itkSetMacro(ForegroundValue, PixelType);
91 itkGetConstMacro(NumberOfBins, int);
92 itkSetMacro(NumberOfBins, int);
94 itkGetConstMacro(NumberOfAngles, int);
95 itkSetMacro(NumberOfAngles, int);
97 itkGetConstMacro(AreaLossTolerance, double);
98 itkSetMacro(AreaLossTolerance, double);
100 itkGetConstMacro(SupportSize, int);
101 itkGetConstMacro(TargetSize, int);
102 itkGetConstMacro(SizeWithThreshold, int);
103 itkGetConstMacro(SizeWithReverseThreshold, int);
105 std::vector<clitk::RelativePositionInformationType> & GetListOfInformation() { return m_ListOfInformation; }
106 std::vector<clitk::RelativePositionOrientationType> & GetListOfOrientation() { return m_ListOfOrientation; }
112 void Print(std::string s=" ", std::ostream & os=std::cout);
114 // I dont want to verify inputs information
115 virtual void VerifyInputInformation() { }
118 RelativePositionAnalyzerFilter();
119 virtual ~RelativePositionAnalyzerFilter() {}
121 itkSetMacro(SupportSize, int);
122 itkSetMacro(TargetSize, int);
123 itkSetMacro(SizeWithThreshold, int);
124 itkSetMacro(SizeWithReverseThreshold, int);
126 PixelType m_BackgroundValue;
127 PixelType m_ForegroundValue;
128 ImagePointer m_Support;
129 ImagePointer m_Object;
130 ImagePointer m_Target;
131 int m_NumberOfAngles;
133 double m_AreaLossTolerance;
136 int m_SizeWithReverseThreshold;
137 int m_SizeWithThreshold;
138 std::vector<double> m_ListOfAngles;
139 std::vector<clitk::RelativePositionInformationType> m_ListOfInformation;
140 std::vector<clitk::RelativePositionOrientationType> m_ListOfOrientation;
142 virtual void GenerateOutputInformation();
143 virtual void GenerateData();
145 typename FloatImageType::Pointer
146 ComputeFuzzyMap(ImageType * object, ImageType * target, double angle);
149 ComputeOptimalThresholds(FloatImageType * map, ImageType * target, int bins, double tolerance,
150 double & threshold, double & reverseThreshold);
152 RelativePositionAnalyzerFilter(const Self&); //purposely not implemented
153 void operator=(const Self&); //purposely not implemented
156 //--------------------------------------------------------------------
158 } // end namespace clitk
159 //--------------------------------------------------------------------
161 #include "clitkRelativePositionAnalyzerFilter.txx"