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 itk::ImageToImageFilter<ImageType, ImageType>
50 /** Standard class typedefs. */
51 typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
52 typedef RelativePositionAnalyzerFilter<ImageType> Self;
53 typedef itk::SmartPointer<Self> Pointer;
54 typedef itk::SmartPointer<const Self> ConstPointer;
56 /** Method for creation through the object factory. */
59 /** Run-time type information (and related methods). */
60 itkTypeMacro(RelativePositionAnalyzerFilter, ImageToImageFilter);
62 /** Some convenient typedefs. */
63 typedef typename ImageType::ConstPointer ImageConstPointer;
64 typedef typename ImageType::Pointer ImagePointer;
65 typedef typename ImageType::RegionType RegionType;
66 typedef typename ImageType::PixelType PixelType;
67 typedef typename ImageType::SpacingType SpacingType;
68 typedef typename ImageType::SizeType SizeType;
69 typedef typename ImageType::IndexType IndexType;
70 typedef typename ImageType::PointType PointType;
72 /** ImageDimension constants */
73 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
75 typedef itk::Image<float, ImageDimension> FloatImageType;
77 /** Input : initial image and object */
78 void SetInputSupport(const ImageType * image);
79 void SetInputObject(const ImageType * image);
80 void SetInputTarget(const ImageType * image);
83 // supportname, objectname multiple targetname
86 itkGetConstMacro(BackgroundValue, PixelType);
87 itkSetMacro(BackgroundValue, PixelType);
89 itkGetConstMacro(ForegroundValue, PixelType);
90 itkSetMacro(ForegroundValue, PixelType);
92 clitk::RelativePositionDirectionType & GetDirection() { return m_Direction; }
93 void SetDirection(clitk::RelativePositionDirectionType & d) { m_Direction = d; }
95 itkGetConstMacro(NumberOfBins, int);
96 itkSetMacro(NumberOfBins, int);
98 itkGetConstMacro(AreaLossTolerance, double);
99 itkSetMacro(AreaLossTolerance, double);
101 itkGetConstMacro(SupportSize, int);
102 itkGetConstMacro(TargetSize, int);
103 itkGetConstMacro(SizeWithThreshold, int);
104 itkGetConstMacro(SizeWithReverseThreshold, int);
106 itkGetConstMacro(Info, clitk::RelativePositionInformationType);
107 itkGetConstMacro(InfoReverse, clitk::RelativePositionInformationType);
113 void Print(std::ostream & os=std::cout);
115 // I dont want to verify inputs information
116 virtual void VerifyInputInformation() { }
119 RelativePositionAnalyzerFilter();
120 virtual ~RelativePositionAnalyzerFilter() {}
122 itkSetMacro(SupportSize, int);
123 itkSetMacro(TargetSize, int);
124 itkSetMacro(SizeWithThreshold, int);
125 itkSetMacro(SizeWithReverseThreshold, int);
127 PixelType m_BackgroundValue;
128 PixelType m_ForegroundValue;
129 ImagePointer m_Support;
130 ImagePointer m_Object;
131 ImagePointer m_Target;
133 double m_AreaLossTolerance;
136 int m_SizeWithReverseThreshold;
137 int m_SizeWithThreshold;
138 clitk::RelativePositionDirectionType m_Direction;
139 clitk::RelativePositionInformationType m_Info;
140 clitk::RelativePositionInformationType m_InfoReverse;
142 virtual void GenerateOutputInformation();
143 virtual void GenerateData();
145 typename FloatImageType::Pointer
146 ComputeFuzzyMap(ImageType * object, ImageType * target, ImageType * support, 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"