21 #ifndef otbJointMassOfBeliefFilter_hxx
22 #define otbJointMassOfBeliefFilter_hxx
28 template <
class TMassFunction>
32 this->SetNumberOfRequiredOutputs(1);
35 typename MassFunctionType::Pointer outputPtr = MassFunctionType::New();
36 this->SetNthOutput(0, outputPtr.GetPointer());
39 template <
class TMassFunction>
42 this->itk::ProcessObject::PushBackInput(input);
45 template <
class TMassFunction>
48 this->itk::ProcessObject::PushFrontInput(input);
51 template <
class TMassFunction>
54 this->itk::ProcessObject::PopBackInput();
57 template <
class TMassFunction>
60 this->itk::ProcessObject::PopFrontInput();
63 template <
class TMassFunction>
66 return static_cast<const MassFunctionType*
>(this->itk::ProcessObject::GetInput(idx));
69 template <
class TMassFunction>
72 if (this->GetNumberOfOutputs() < 1)
76 return static_cast<MassFunctionType*
>(this->itk::ProcessObject::GetOutput(0));
79 template <
class TMassFunction>
83 typename MassFunctionType::Pointer outputPtr = this->GetOutput();
86 for (
unsigned int i = 0; i < this->GetNumberOfInputs(); ++i)
89 typename MassFunctionType::ConstPointer inputPtr = this->GetInput(i);
92 this->CombineMasses(inputPtr, outputPtr);
96 template <
class TMassFunction>
100 Superclass::PrintSelf(os, indent);
103 template <
class TMassFunction>
107 if (output->IsEmpty())
117 typename MassFunctionType::Pointer newJointMass = MassFunctionType::New();
120 MassType conflict = itk::NumericTraits<MassType>::Zero;
131 for (
typename LabelSetOfSetType::const_iterator inputIt = inputSupportSet.begin(); inputIt != inputSupportSet.end(); ++inputIt)
133 for (
typename LabelSetOfSetType::const_iterator currentIt = currentSupportSet.begin(); currentIt != currentSupportSet.end(); ++currentIt)
137 std::insert_iterator<LabelSetType> interIt(intersectionSet, intersectionSet.begin());
140 std::set_intersection(inputIt->begin(), inputIt->end(), currentIt->begin(), currentIt->end(), interIt);
143 MassType massProduct = input->GetMass((*inputIt)) * output->GetMass((*currentIt));
146 if (intersectionSet.empty())
148 conflict += massProduct;
154 MassType intersectionMass = newJointMass->GetMass(intersectionSet);
157 intersectionMass += massProduct;
160 newJointMass->SetMass(intersectionSet, intersectionMass);
163 jointSupport.insert(intersectionSet);
168 MassType conflictCoefficient = 1 / (1 - conflict);
171 for (
typename LabelSetOfSetType::const_iterator it = jointSupport.begin(); it != jointSupport.end(); ++it)
174 MassType jointMass = newJointMass->GetMass((*it));
177 jointMass *= conflictCoefficient;
180 newJointMass->SetMass((*it), jointMass);
184 output->Copy(newJointMass);
189 #ifndef OTB_MANUAL_INSTANTIATION