Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
c0aa9bd3
Commit
c0aa9bd3
authored
12 years ago
by
Julien Malik
Browse files
Options
Downloads
Patches
Plain Diff
ENH: ListSampleGenerator, reorganize code, remove a useless member
parent
00b9d810
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Learning/otbListSampleGenerator.h
+0
-1
0 additions, 1 deletion
Code/Learning/otbListSampleGenerator.h
Code/Learning/otbListSampleGenerator.txx
+23
-31
23 additions, 31 deletions
Code/Learning/otbListSampleGenerator.txx
with
23 additions
and
32 deletions
Code/Learning/otbListSampleGenerator.h
+
0
−
1
View file @
c0aa9bd3
...
...
@@ -170,7 +170,6 @@ private:
// useful, when dealing with small polygon area (1 or two pixels)
// false by default
std
::
string
m_ClassKey
;
double
m_ClassMinSize
;
ListSamplePointerType
m_TrainingListSample
;
ListLabelPointerType
m_TrainingListLabel
;
...
...
This diff is collapsed.
Click to expand it.
Code/Learning/otbListSampleGenerator.txx
+
23
−
31
View file @
c0aa9bd3
...
...
@@ -65,8 +65,7 @@ ListSampleGenerator<TImage, TVectorData>
m_MaxValidationSize(-1),
m_ValidationTrainingProportion(0.0),
m_PolygonEdgeInclusion(false),
m_ClassKey("Class"),
m_ClassMinSize(-1)
m_ClassKey("Class")
{
this->SetNumberOfRequiredInputs(2);
this->SetNumberOfRequiredOutputs(1);
...
...
@@ -263,27 +262,6 @@ ListSampleGenerator<TImage, TVectorData>
}
}
// Compute the class with the minimum number of pixels
if (!m_ClassesSize.empty())
{
double minSize = itk::NumericTraits<double>::max();
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin();
itmap != m_ClassesSize.end();
++itmap)
{
if (minSize > itmap->second)
{
minSize = itmap->second;
}
}
m_ClassMinSize = minSize;
}
else
{
itkGenericExceptionMacro(<< "No training sample found inside image")
}
}
template <class TImage, class TVectorData>
...
...
@@ -293,16 +271,30 @@ ListSampleGenerator<TImage, TVectorData>
{
m_ClassesProbTraining.clear();
m_ClassesProbValidation.clear();
// Sanity check
if (m_ClassesSize.empty())
{
itkGenericExceptionMacro(<< "No training sample found inside image");
}
//Go through the classes size to find the smallest one
double minSizeTraining = m_ClassMinSize;
double minSizeValidation = minSizeTraining;
// Go through the classes size to find the smallest one
double minSize = itk::NumericTraits<double>::max();
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin();
itmap != m_ClassesSize.end();
++itmap)
{
if (minSize > itmap->second)
{
minSize = itmap->second;
}
}
//Apply the proportion between training and validation samples (all training by default)
minSizeTraining *
=
(1.0 - m_ValidationTrainingProportion);
minSizeValidation
*
= m_ValidationTrainingProportion;
//
Apply the proportion between training and validation samples (all training by default)
double
minSizeTraining
= minSize
* (1.0 - m_ValidationTrainingProportion);
double
minSizeValidation =
minSize *
m_ValidationTrainingProportion;
//Apply the limit if specified by the user
//
Apply the limit if specified by the user
if ((m_MaxTrainingSize != -1) && (m_MaxTrainingSize < minSizeTraining))
{
minSizeTraining = m_MaxTrainingSize;
...
...
@@ -312,7 +304,7 @@ ListSampleGenerator<TImage, TVectorData>
minSizeValidation = m_MaxValidationSize;
}
//Compute the probability selection for each class
//
Compute the probability selection for each class
for (std::map<ClassLabelType, double>::const_iterator itmap = m_ClassesSize.begin();
itmap != m_ClassesSize.end();
++itmap)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment