ANIMA  4.0
animaSegmentationMeasuresImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <itkNumericTraits.h>
5 
6 namespace anima
7 {
8 
14 {
15 public:
16  // default constructor
18  {
19  m_Source = 0;
20  m_Target = 0;
21  m_Union = 0;
22  m_TrueNegative = 0;
23  m_Intersection = 0;
26  }
27 
28  // added for completeness
30  {
31  if(this != &l)
32  {
33  m_Source = l.m_Source;
34  m_Target = l.m_Target;
35  m_Union = l.m_Union;
40  }
41  return *this;
42  }
43 
44  unsigned long m_Source;
45  unsigned long m_Target;
46  unsigned long m_Union;
47  unsigned long m_TrueNegative;
48  unsigned long m_Intersection;
49  unsigned long m_SourceComplement;
50  unsigned long m_TargetComplement;
51 };
52 
53 template<typename TLabelImage>
55 {
56 public:
60  typedef itk::SmartPointer<Self> Pointer;
61  typedef itk::SmartPointer<const Self> ConstPointer;
62 
64  itkNewMacro(Self)
65 
66 
68 
69 
70  typedef TLabelImage LabelImageType;
71  typedef typename TLabelImage::Pointer LabelImagePointer;
72  typedef typename TLabelImage::ConstPointer LabelImageConstPointer;
73 
74  typedef typename TLabelImage::RegionType RegionType;
75  typedef typename TLabelImage::SizeType SizeType;
76  typedef typename TLabelImage::IndexType IndexType;
77 
78  typedef typename TLabelImage::PixelType LabelType;
79 
81  typedef typename itk::NumericTraits<LabelType>::RealType RealType;
82 
84  typedef std::map<LabelType, SegPerfLabelSetMeasures> MapType;
85  typedef typename MapType::iterator MapIterator;
86  typedef typename MapType::const_iterator MapConstIterator;
87 
89  itkStaticConstMacro(ImageDimension, unsigned int, TLabelImage::ImageDimension);
90 
92  void SetSourceImage(const LabelImageType* image)
93  {
94  this->SetNthInput(0, const_cast<LabelImageType*>(image));
95  }
96 
98  void SetTargetImage(const LabelImageType* image)
99  {
100  this->SetNthInput(1, const_cast<LabelImageType*>(image));
101  }
102 
105  {
106  return this->GetInput(0);
107  }
108 
111  {
112  return this->GetInput(1);
113  }
114 
117  {
118  return this->m_LabelSetMeasures;
119  }
120 
125  RealType getSensitivity();
126  RealType getSpecificity();
127  RealType getPPV();
128  RealType getNPV();
129  RealType getUnionOverlap();
130  RealType getMeanOverlap();
131  RealType getRelativeVolumeError();
132 
133 
135  RealType getSensitivity(LabelType);
136  RealType getSpecificity(LabelType);
137  RealType getPPV(LabelType);
138  RealType getNPV(LabelType);
139  RealType getUnionOverlap( LabelType );
140  RealType getMeanOverlap( LabelType );
141  RealType getRelativeVolumeError( LabelType );
142 
145  {
146  return this->getUnionOverlap();
147  }
148 
150  {
151  return this->getMeanOverlap();
152  }
153 
155  {
156  return this->getMeanOverlap( label );
157  }
158 
160  {
161  return this->getUnionOverlap( label );
162  }
163 
164 protected:
167 
168  void BeforeThreadedGenerateData() ITK_OVERRIDE;
169  void AfterThreadedGenerateData() ITK_OVERRIDE;
170 
172  void DynamicThreadedGenerateData(const RegionType &) ITK_OVERRIDE;
173 
174 private:
175  ITK_DISALLOW_COPY_AND_ASSIGN(SegmentationMeasuresImageFilter);
176 
177  double m_fNbOfPixels;
178 
179  std::vector<MapType> m_LabelSetMeasuresPerThread;
180  MapType m_LabelSetMeasures;
181 }; // end of class
182 
183 } // end namespace anima
184 
Implements a class to handle thread number in a dynamic way for multithreaded methods needing thread ...
STL namespace.
anima::NumberedThreadImageToImageFilter< TLabelImage, TLabelImage > Superclass
std::map< LabelType, SegPerfLabelSetMeasures > MapType
itk::NumericTraits< LabelType >::RealType RealType
SegPerfLabelSetMeasures & operator=(const SegPerfLabelSetMeasures &l)