Skip to content
Snippets Groups Projects
Commit 17b4683b authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

MRG

parents d50ef61d 1094393d
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,8 @@ public:
typedef TProdListLabel ProdListLabelType;
typedef typename ProdListLabelType::Pointer ProdListLabelPointerType;
typedef int ClassLabelType;
/** Type for the confusion matrix */
typedef itk::VariableSizeMatrix<double> ConfusionMatrixType;
......@@ -73,6 +75,11 @@ public:
itkGetMacro(NumberOfSamples, unsigned long);
itkGetMacro(ConfusionMatrix, ConfusionMatrixType);
std::map<ClassLabelType, int> GetMapOfClasses() const
{
return m_MapOfClasses;
}
protected:
ConfusionMatrixCalculator();
virtual ~ConfusionMatrixCalculator() {}
......@@ -88,7 +95,7 @@ private:
double m_KappaIndex;
double m_OverallAccuracy;
std::map<int,int> m_MapOfClasses;
std::map<ClassLabelType, int> m_MapOfClasses;
unsigned short m_NumberOfClasses;
unsigned long m_NumberOfSamples;
......
......@@ -66,8 +66,7 @@ ConfusionMatrixCalculator<TRefListLabel,TProdListLabel>
m_NumberOfSamples = m_ReferenceLabels->Size();
// count de number of classes
// count the number of classes
int countClasses = 0;
while( refIterator != m_ReferenceLabels->End() )
{
......
......@@ -61,8 +61,7 @@ public:
itkNewMacro(Self);
typedef TImage ImageType;
typedef TVectorData VectorDataType;
typedef TVectorData VectorDataType;
typedef typename VectorDataType::Pointer VectorDataPointerType;
typedef itk::PreOrderTreeIterator<typename VectorDataType::DataTreeType> TreeIteratorType;
......@@ -73,7 +72,8 @@ public:
typedef typename ListSampleType::Pointer ListSamplePointerType;
/** List to store the corresponding labels */
typedef itk::FixedArray<int, 1> LabelType; //note could be templated by an std:::string
typedef int ClassLabelType;
typedef itk::FixedArray<ClassLabelType, 1> LabelType; //note could be templated by an std:::string
typedef itk::Statistics::ListSample<LabelType> ListLabelType;
typedef typename ListLabelType::Pointer ListLabelPointerType;
......@@ -102,7 +102,7 @@ public:
itkSetClampMacro(ValidationTrainingProportion, double, 0.0, 1.0);
itkGetConstMacro(NumberOfClasses, unsigned short);
typedef std::map<int, int> SampleNumberType;
typedef std::map<ClassLabelType, int> SampleNumberType;
SampleNumberType GetClassesSamplesNumberTraining(void) const
{
......@@ -151,12 +151,12 @@ private:
ListLabelPointerType m_ValidationListLabel;
std::map<int, double> m_ClassesSize;
std::map<int, double> m_ClassesProbTraining;
std::map<int, double> m_ClassesProbValidation;
std::map<ClassLabelType, double> m_ClassesSize;
std::map<ClassLabelType, double> m_ClassesProbTraining;
std::map<ClassLabelType, double> m_ClassesProbValidation;
std::map<int, int> m_ClassesSamplesNumberTraining; //Just a counter
std::map<int, int> m_ClassesSamplesNumberValidation; //Just a counter
std::map<ClassLabelType, int> m_ClassesSamplesNumberTraining; //Just a counter
std::map<ClassLabelType, int> m_ClassesSamplesNumberValidation; //Just a counter
typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
RandomGeneratorType::Pointer m_RandomGenerator;
......
......@@ -228,7 +228,7 @@ ListSampleGenerator<TImage,TVectorData>
//Go throught the classes size to find the smallest one
double minSizeTraining = -1;
for (std::map<int, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
{
if ((minSizeTraining < 0) || (minSizeTraining > itmap->second))
{
......@@ -254,11 +254,11 @@ ListSampleGenerator<TImage,TVectorData>
}
//Compute the probability selection for each class
for (std::map<int, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
{
m_ClassesProbTraining[itmap->first] = minSizeTraining / itmap->second;
}
for (std::map<int, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
{
m_ClassesProbValidation[itmap->first] = minSizeValidation / itmap->second;
}
......@@ -280,7 +280,8 @@ ListSampleGenerator<TImage,TVectorData>
}
else
{
for (std::map<int, double>::const_iterator itmap = m_ClassesSize.begin(); itmap != m_ClassesSize.end(); ++itmap)
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin();
itmap != m_ClassesSize.end(); ++itmap)
{
os << indent << itmap->first << ": " << itmap->second << "\n";
}
......@@ -294,13 +295,13 @@ ListSampleGenerator<TImage,TVectorData>
else
{
os << indent << "** Selection probability:\n";
for (std::map<int, double>::const_iterator itmap = m_ClassesProbTraining.begin();
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesProbTraining.begin();
itmap != m_ClassesProbTraining.end(); ++itmap)
{
os << indent << itmap->first << ": " << itmap->second << "\n";
}
os << indent << "** Number of selected samples:\n";
for (std::map<int, int>::const_iterator itmap = m_ClassesSamplesNumberTraining.begin();
for (std::map<ClassLabelType, int>::const_iterator itmap = m_ClassesSamplesNumberTraining.begin();
itmap != m_ClassesSamplesNumberTraining.end(); ++itmap)
{
os << indent << itmap->first << ": " << itmap->second << "\n";
......@@ -315,13 +316,13 @@ ListSampleGenerator<TImage,TVectorData>
else
{
os << indent << "** Selection probability:\n";
for (std::map<int, double>::const_iterator itmap = m_ClassesProbValidation.begin();
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesProbValidation.begin();
itmap != m_ClassesProbValidation.end(); ++itmap)
{
os << indent << itmap->first << ": " << itmap->second << "\n";
}
os << indent << "** Number of selected samples:\n";
for (std::map<int, int>::const_iterator itmap = m_ClassesSamplesNumberValidation.begin();
for (std::map<ClassLabelType, int>::const_iterator itmap = m_ClassesSamplesNumberValidation.begin();
itmap != m_ClassesSamplesNumberValidation.end(); ++itmap)
{
os << indent << itmap->first << ": " << itmap->second << "\n";
......
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