Skip to content
Snippets Groups Projects
Commit 23129321 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: Mantis-1319: ignore empty classes

parent 3e88297d
No related branches found
No related tags found
No related merge requests found
...@@ -50,15 +50,23 @@ SamplingRateCalculator ...@@ -50,15 +50,23 @@ SamplingRateCalculator
MapRateType::iterator it = m_RatesByClass.begin(); MapRateType::iterator it = m_RatesByClass.begin();
for (; it != m_RatesByClass.end() ; ++it) for (; it != m_RatesByClass.end() ; ++it)
{ {
if (smallestNbofSamples > it->second.Tot) if (it->second.Tot)
{ {
smallestNbofSamples = it->second.Tot; if (smallestNbofSamples > it->second.Tot)
{
smallestNbofSamples = it->second.Tot;
}
}
else
{
otbWarningMacro("Ignoring empty class " << it->first);
} }
} }
// Check if there is an empty class // Check if there is at least one non-empty class
if (smallestNbofSamples == 0UL) if (smallestNbofSamples == itk::NumericTraits<unsigned long>::max())
{ {
otbWarningMacro("There is an empty class, sample size is set to zero!"); otbWarningMacro("There are only empty classes, sample size is set to zero!");
smallestNbofSamples = 0UL;
} }
this->SetNbOfSamplesAllClasses( smallestNbofSamples ); this->SetNbOfSamplesAllClasses( smallestNbofSamples );
} }
...@@ -70,7 +78,15 @@ SamplingRateCalculator ...@@ -70,7 +78,15 @@ SamplingRateCalculator
MapRateType::iterator it = m_RatesByClass.begin(); MapRateType::iterator it = m_RatesByClass.begin();
for (; it != m_RatesByClass.end() ; ++it) for (; it != m_RatesByClass.end() ; ++it)
{ {
it->second.Required = dRequiredNbSamples; if (it->second.Tot)
{
it->second.Required = dRequiredNbSamples;
}
else
{
// ignore empty classes
it->second.Required = 0UL;
}
this->UpdateRate(it->first); this->UpdateRate(it->first);
} }
} }
......
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