21 #ifndef otbHooverMatrixFilter_hxx
22 #define otbHooverMatrixFilter_hxx
30 template <
class TLabelMap>
33 this->SetNumberOfRequiredInputs(2);
39 template <
class TLabelMap>
42 this->SetInput(0, gt);
46 template <
class TLabelMap>
49 this->SetInput(1, ms);
53 template <
class TLabelMap>
56 return this->GetInput(0);
60 template <
class TLabelMap>
63 return this->GetInput(1);
66 template <
class TLabelMap>
70 Superclass::BeforeThreadedGenerateData();
73 m_NumberOfRegionsGT = this->GetGroundTruthLabelMap()->GetNumberOfLabelObjects();
74 m_NumberOfRegionsMS = this->GetMachineSegmentationLabelMap()->GetNumberOfLabelObjects();
75 m_LabelsGT = this->GetGroundTruthLabelMap()->GetLabels();
76 m_Matrix.SetSize(m_NumberOfRegionsGT, m_NumberOfRegionsMS);
80 template <
class TLabelMap>
85 unsigned long currentRegionMS = 0;
86 unsigned long currentRegionGT = 0;
88 LabelType currentLabelGT = labelObject->GetLabel();
89 for (
unsigned long k = 0; k < m_NumberOfRegionsGT; k++)
91 if (currentLabelGT == m_LabelsGT[k])
99 typedef typename LabelObjectType::ConstLineIterator IteratorType;
100 IteratorType lit = IteratorType(labelObject);
101 while (!lit.IsAtEnd())
103 IndexType idx = lit.GetLine().GetIndex();
104 unsigned long length = lit.GetLine().GetLength();
105 for (
unsigned long i = 0; i < length; i++)
109 for (
unsigned long j = currentRegionMS; j < (currentRegionMS + m_NumberOfRegionsMS); j++)
112 const LabelObjectType* regionMS = this->GetMachineSegmentationLabelMap()->GetNthLabelObject(j % m_NumberOfRegionsMS);
113 if (regionMS->HasIndex(idx))
115 currentRegionMS = j % m_NumberOfRegionsMS;
116 m_Matrix(currentRegionGT, currentRegionMS)++;