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
d0ca2b6e
Commit
d0ca2b6e
authored
14 years ago
by
Mickael Savinaud
Browse files
Options
Downloads
Patches
Plain Diff
STYLE: clean code and enhance comments
parent
6462c3f6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classification/otbValidateImagesClassifier.cxx
+11
-7
11 additions, 7 deletions
Classification/otbValidateImagesClassifier.cxx
with
11 additions
and
7 deletions
Classification/otbValidateImagesClassifier.cxx
+
11
−
7
View file @
d0ca2b6e
...
...
@@ -24,9 +24,7 @@
//Image
#include
"otbImage.h"
#include
"otbVectorImage.h"
#include
"otbImageList.h"
#include
"otbImageFileReader.h"
#include
"otbVectorImageToImageListFilter.h"
#include
"otbVectorData.h"
#include
"otbVectorDataFileReader.h"
#include
"otbListSampleGenerator.h"
...
...
@@ -82,13 +80,11 @@ int ValidateImagesClassifier::Describe(ApplicationDescriptor* descriptor)
int
ValidateImagesClassifier
::
Execute
(
otb
::
ApplicationOptionsResult
*
parseResult
)
{
// Input Image
//typedef double ValueType;
//typedef unsigned short PixelType; // def by manuel
typedef
float
PixelType
;
typedef
otb
::
VectorImage
<
PixelType
,
2
>
VectorImageType
;
typedef
otb
::
Image
<
PixelType
,
2
>
ImageType
;
typedef
otb
::
ImageFileReader
<
VectorImageType
>
ReaderType
;
typedef
int
LabeledPixelType
;
typedef
int
LabeledPixelType
;
typedef
otb
::
Image
<
LabeledPixelType
,
2
>
LabeledImageType
;
// Training vectordata
...
...
@@ -110,6 +106,7 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
// Statistic XML file Reader
typedef
otb
::
StatisticsXMLFileReader
<
MeasurementType
>
StatisticsReader
;
// Enhance List Sample
typedef
otb
::
Statistics
::
ShiftScaleSampleListFilter
<
ListSampleType
,
ListSampleType
>
ShiftScaleFilterType
;
...
...
@@ -125,17 +122,21 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
ListSampleType
,
LabelListSampleType
,
MeasurementVectorFunctorType
>
SVMEstimatorType
;
// Estimate performance on validation sample
typedef
otb
::
SVMClassifier
<
ListSampleType
,
LabelType
::
ValueType
>
ClassifierType
;
typedef
otb
::
ConfusionMatrixCalculator
<
LabelListSampleType
,
LabelListSampleType
>
ConfusionMatrixCalculatorType
;
typedef
ClassifierType
::
OutputType
ClassifierOutputType
;
//Create validation list samples and validation label list samples
ConcatenateLabelListSampleFilterType
::
Pointer
concatenateValidationLabels
=
ConcatenateLabelListSampleFilterType
::
New
();
ConcatenateListSampleFilterType
::
Pointer
concatenateValidationSamples
=
ConcatenateListSampleFilterType
::
New
();
//--------------------------
// Load measuremnts from input images
unsigned
int
nbBands
=
0
;
//Iterate over all input images
for
(
int
imgIndex
=
0
;
imgIndex
<
parseResult
->
GetNumberOfParameters
(
"InputImages"
);
++
imgIndex
)
...
...
@@ -180,9 +181,9 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
concatenateValidationSamples
->
Update
();
concatenateValidationLabels
->
Update
();
//--------------------------
// Normalize the samples
// Read the mean and variance form the XML file (estimate with the otbEstimateImagesStatistics application)
MeasurementType
meanMeasurentVector
;
MeasurementType
varianceMeasurentVector
;
if
(
parseResult
->
IsOptionPresent
(
"ImagesStatistics"
))
...
...
@@ -210,6 +211,7 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
validationShiftScaleFilter
->
SetScales
(
varianceMeasurentVector
);
validationShiftScaleFilter
->
Update
();
//--------------------------
// split the data set into training/validation set
ListSampleType
::
Pointer
validationListSample
=
validationShiftScaleFilter
->
GetOutputSampleList
();
LabelListSampleType
::
Pointer
validationLabeledListSample
=
concatenateValidationLabels
->
GetOutputSampleList
();
...
...
@@ -217,6 +219,7 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
std
::
cout
<<
"Size of validation set: "
<<
validationListSample
->
Size
()
<<
std
::
endl
;
std
::
cout
<<
"Size of labeled validation set: "
<<
validationLabeledListSample
->
Size
()
<<
std
::
endl
;
//--------------------------
// Load svm model
ModelPointerType
modelSVM
=
ModelType
::
New
();
modelSVM
->
LoadModel
(
parseResult
->
GetParameterString
(
"SVMmodel"
).
c_str
());
...
...
@@ -258,6 +261,7 @@ int ValidateImagesClassifier::Execute(otb::ApplicationOptionsResult* parseResult
std
::
cout
<<
"F-score of the different class: "
<<
confMatCalc
->
GetFScores
()
<<
std
::
endl
;
std
::
cout
<<
"Kappa index: "
<<
confMatCalc
->
GetKappaIndex
()
<<
std
::
endl
;
//--------------------------
// Save output in a ascii file (if needed)
if
(
parseResult
->
IsOptionPresent
(
"OutputPerfEstimation"
))
{
...
...
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