Skip to content
Snippets Groups Projects
Commit 3366436e authored by Aurélien Bricier's avatar Aurélien Bricier
Browse files

DOC: added class documentation and cleaned code

parent 44192b38
No related branches found
No related tags found
No related merge requests found
......@@ -31,11 +31,37 @@
namespace otb
{
/** \class VectorDataToVectorDataFilter
* \brief .
*
/** \class VectorDataToDSValidatedVectorDataFilter
* \brief VectorData filter validating data nodes using
* Dempster-Shafer theory.
*
* This filter takes as input a vector data containing
* features score and validate (or not) each data node
* according to these features score, a fuzzy model corresponding
* to each feature and a criterion according to the Dempster-Shafer
* theory. By default the filter is (for now) parametrized to process
* VectorDatas providing by the VectorDataToRoadDescriptionFilter.
* The hypothesis must be set using the SetHypothesis method.
* The convention is for each feature Fe, a mass of Belief is defined
* with two variables named Fe and Fe_. Thus, an hypothesis must declared:
* VectorDataToVectorDataFilter::LabelSetType hyp;
* hyp.insert("Fe(i)");
* hyp.insert("Fe(j)_");
* hyp.insert("Fe(k)_");
*
* Fe(i), Fe(j) and Fe(k) being descriptors.
*
* The criterion can be set through SetCriterionFormula() as a
* string refering to "Belief" and "Plausibility" from the
* Dempster-Shafer theory. By default the criterion is:
* "((Belief + Plausibility)/2) >= 0.5"
*
* The concidered features will be the intersection between
* the features embedded in this filter and the features embedded
* in the input vector data. For now, the filter uses "NDVI" and
* "RADIOM" features.
*
*
* \ingroup VectorDataFilter
* \sa VectorDataToRoadDescriptionFilter
* \sa VectorDataToBuildingDescriptionFilter
......@@ -87,14 +113,6 @@ public:
itkGetConstMacro(CriterionFormula, std::string);
itkSetMacro(CriterionFormula, std::string);
itkGetConstMacro(CriterionThreshold, double);
itkSetMacro(CriterionThreshold, double);
/*
itkGetConstMacro(Hypothesis, LabelSetType);
itkSetMacro(Hypothesis, LabelSetType);
*/
LabelSetType GetHypothesis()
{
return m_Hypothesis;
......@@ -116,6 +134,12 @@ protected:
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
std::string GetNextID()
{
std::ostringstream oss;
oss << m_CurrentID++;
return oss.str();
}
private:
VectorDataToDSValidatedVectorDataFilter(const Self &); //purposely not implemented
......@@ -130,8 +154,7 @@ private:
typename ParserType::Pointer m_Parser;
std::string m_CriterionFormula;
double m_CriterionThreshold;
unsigned int m_CurrentID;
};
} // end namespace otb
......
......@@ -29,20 +29,20 @@ namespace otb
template <class TVectorData, class TPrecision>
VectorDataToDSValidatedVectorDataFilter<TVectorData, TPrecision>
::VectorDataToDSValidatedVectorDataFilter() :
m_CriterionFormula("(Belief + Plausibility)/2"),
m_CriterionThreshold(0.5)
m_CriterionFormula("((Belief + Plausibility)/2) >= 0.5"),
m_CurrentID(0)
{
this->SetNumberOfRequiredInputs(1);
//Default road descriptors
std::vector<double> ndvi, radiom, lsd, shadow;
ndvi.push_back(0.25); ndvi.push_back(0.5);ndvi.push_back(0.75); ndvi.push_back(0.99);
radiom.push_back(0.25); radiom.push_back(0.5); radiom.push_back(0.75); radiom.push_back(0.90);
lsd.push_back(0.25); lsd.push_back(0.5); lsd.push_back(0.75); lsd.push_back(0.96);
shadow.push_back(0.25); shadow.push_back(0.5); shadow.push_back(0.75); shadow.push_back(0.98);
//lsd.push_back(0.25); lsd.push_back(0.5); lsd.push_back(0.75); lsd.push_back(0.96);
//shadow.push_back(0.25); shadow.push_back(0.5); shadow.push_back(0.75); shadow.push_back(0.98);
AddDescriptor("NDVI", ndvi);
AddDescriptor("RADIOM", radiom);
AddDescriptor("LSD", lsd);
//AddDescriptor("LSD", lsd);
//AddDescriptor("SHADOW", shadow);
m_Parser = ParserType::New();
......@@ -105,7 +105,7 @@ VectorDataToDSValidatedVectorDataFilter<TVectorData, TPrecision>
}
//Initialize parser
std::cout << m_CriterionFormula << std::endl;
//std::cout << m_CriterionFormula << std::endl;
m_Parser->SetExpr(m_CriterionFormula);
m_Parser->DefineVar("Belief", &m_Bel);
m_Parser->DefineVar("Plausibility", &m_Plau);
......@@ -150,17 +150,15 @@ VectorDataToDSValidatedVectorDataFilter<TVectorData, TPrecision>
H.insert(fuzName);
H_.insert(fuzName_);
mass->SetMass(H, m_FuzzyVars[i]->GetMembership(fuzName,
(double)(currentGeometry->GetFieldAsInt(fuzName))/100.0));
mass->SetMass(H_, m_FuzzyVars[i]->GetMembership(fuzName_,
(double)(currentGeometry->GetFieldAsInt(fuzName))/100.0));
std::cout << fuzName << " : " << (double)(currentGeometry->GetFieldAsInt(fuzName))/100.
<< " " << m_FuzzyVars[i]->GetMembership(fuzName, (double)(currentGeometry->GetFieldAsInt(fuzName))/100.0) << std::endl;
std::cout << fuzName_ << " : " << (double)(currentGeometry->GetFieldAsInt(fuzName))/100.
<< " " << m_FuzzyVars[i]->GetMembership(fuzName_, (double)(currentGeometry->GetFieldAsInt(fuzName))/100.0) << std::endl;
mass->SetMass(H, m_FuzzyVars[i]->GetMembership(fuzName, currentGeometry->GetFieldAsDouble(fuzName)));
mass->SetMass(H_, m_FuzzyVars[i]->GetMembership(fuzName_, currentGeometry->GetFieldAsDouble(fuzName)));
/*
std::cout << fuzName << " : " << currentGeometry->GetFieldAsDouble(fuzName)
<< " " << m_FuzzyVars[i]->GetMembership(fuzName, currentGeometry->GetFieldAsInt(fuzName)) << std::endl;
std::cout << fuzName_ << " : " << currentGeometry->GetFieldAsDouble(fuzName)
<< " " << m_FuzzyVars[i]->GetMembership(fuzName_, currentGeometry->GetFieldAsDouble(fuzName)) << std::endl;
*/
mass->EstimateUncertainty();
jointMassFilter->PushBackInput(mass);
......@@ -169,20 +167,21 @@ VectorDataToDSValidatedVectorDataFilter<TVectorData, TPrecision>
jointMassFilter->Update();
m_Bel = jointMassFilter->GetOutput()->GetBelief(m_Hypothesis);
m_Plau = jointMassFilter->GetOutput()->GetPlausibility(m_Hypothesis);
/*
std::cout << "Bel : " << m_Bel << std::endl;
std::cout << "Plau: " << m_Plau << std::endl;
if (m_Parser->Eval() >= m_CriterionThreshold)
*/
if (m_Parser->Eval())
{
std::cout << "Feature Validated : " << m_Parser->Eval() << std::endl;
//std::cout << "Feature Validated : " << m_Parser->Eval() << std::endl;
currentGeometry->SetNodeId(this->GetNextID());
this->GetOutput(0)->GetDataTree()->Add(currentGeometry, folder);
}
else
{
std::cout << "Feature Rejected : " << m_Parser->Eval() << std::endl;
//std::cout << "Feature Rejected : " << m_Parser->Eval() << std::endl;
}
itVector.GoToEnd();//TEST ONLY###########################################
//itVector.GoToEnd();//TEST ONLY###########################################
}
++itVector;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment