22 #ifndef otbMRFSamplerMAP_h
23 #define otbMRFSamplerMAP_h
44 template <
class TInput1,
class TInput2>
68 if (this->m_NumberOfClasses == 0)
70 itkExceptionMacro(<<
"NumberOfClasses has to be greater than 0.");
73 this->m_EnergyBefore = this->m_EnergyFidelity->GetValue(itData, itRegul.GetCenterPixel());
74 this->m_EnergyBefore += this->m_Lambda * this->m_EnergyRegularization->GetValue(itRegul, itRegul.GetCenterPixel());
77 this->m_EnergyAfter = this->m_EnergyBefore;
78 this->m_Value = itRegul.GetCenterPixel();
81 while (valueCurrent <
static_cast<LabelledImagePixelType>(this->GetNumberOfClasses()) && valueCurrent != itk::NumericTraits<LabelledImagePixelType>::max())
83 this->m_EnergyCurrent = this->m_EnergyFidelity->GetValue(itData, valueCurrent);
84 this->m_EnergyCurrent += this->m_Lambda * this->m_EnergyRegularization->GetValue(itRegul, valueCurrent);
85 if (this->m_EnergyCurrent < this->m_EnergyAfter)
87 this->m_EnergyAfter = this->m_EnergyCurrent;
88 this->m_Value = valueCurrent;
93 this->m_DeltaEnergy = this->m_EnergyAfter - this->m_EnergyBefore;