Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
e5e20deb
Commit
e5e20deb
authored
Apr 06, 2011
by
Mickael Savinaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: add extract ROI to manage large input
parent
aab94472
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
11 deletions
+41
-11
Classification/otbImageSVMClassifier.cxx
Classification/otbImageSVMClassifier.cxx
+41
-11
No files found.
Classification/otbImageSVMClassifier.cxx
View file @
e5e20deb
...
...
@@ -43,6 +43,7 @@
#include "itkTimeProbe.h"
#include "otbStandardFilterWatcher.h"
#include "otbMultiChannelExtractROI.h"
namespace
otb
{
...
...
@@ -59,6 +60,14 @@ int ImageSVMClassifier::Describe(ApplicationDescriptor* descriptor)
"svm"
,
1
,
true
,
ApplicationDescriptor
::
FileName
);
descriptor
->
AddOption
(
"OutputLabeledImage"
,
"Output labeled image"
,
"out"
,
1
,
true
,
ApplicationDescriptor
::
FileName
);
descriptor
->
AddOption
(
"ROIStartX"
,
""
,
"x"
,
1
,
false
,
ApplicationDescriptor
::
Integer
);
descriptor
->
AddOption
(
"ROIStartY"
,
""
,
"y"
,
1
,
false
,
ApplicationDescriptor
::
Integer
);
descriptor
->
AddOption
(
"ROISizeX"
,
""
,
"sx"
,
1
,
false
,
ApplicationDescriptor
::
Integer
);
descriptor
->
AddOption
(
"ROISizeY"
,
""
,
"sy"
,
1
,
false
,
ApplicationDescriptor
::
Integer
);
return
EXIT_SUCCESS
;
}
...
...
@@ -74,6 +83,9 @@ int ImageSVMClassifier::Execute(otb::ApplicationOptionsResult* parseResult)
typedef
otb
::
ImageFileReader
<
VectorImageType
>
ReaderType
;
typedef
otb
::
ImageFileWriter
<
VectorImageType
>
WriterType
;
//typedef otb::ExtractROIBase<VectorImageType, VectorImageType> ExtractROIType;
typedef
otb
::
MultiChannelExtractROI
<
PixelType
,
PixelType
>
ExtractROIType
;
// Statistic XML file Reader
typedef
itk
::
VariableLengthVector
<
PixelType
>
MeasurementType
;
typedef
otb
::
StatisticsXMLFileReader
<
MeasurementType
>
StatisticsReader
;
...
...
@@ -137,21 +149,39 @@ int ImageSVMClassifier::Execute(otb::ApplicationOptionsResult* parseResult)
changeLabelFilter
->
SetInput
(
classificationFilter
->
GetOutput
());
changeLabelFilter
->
SetNumberOfComponentsPerPixel
(
3
);
/*for (ClassesMapType::iterator it = m_ClassesMap.begin(); it != m_ClassesMap.end(); ++it)
{
OverlayImageType::PixelType color(3);
color[0] = static_cast<unsigned char>((*it)->GetColor()[0] * 255);
color[1] = static_cast<unsigned char>((*it)->GetColor()[1] * 255);
color[2] = static_cast<unsigned char>((*it)->GetColor()[2] * 255);
changeLabelFilter->SetChange((*it)->GetId(), color);
}*/
//--------------------------
// Save labeled Image
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetFileName
(
parseResult
->
GetParameterString
(
"OutputLabeledImage"
));
writer
->
SetInput
(
changeLabelFilter
->
GetOutput
());
// Extract ROI if needed
if
(
(
parseResult
->
IsOptionPresent
(
"ROIStartX"
))
&&
(
parseResult
->
IsOptionPresent
(
"ROIStartY"
))
&&
(
parseResult
->
IsOptionPresent
(
"ROISizeX"
))
&&
(
parseResult
->
IsOptionPresent
(
"ROISizeY"
))
)
{
ExtractROIType
::
Pointer
extract
=
ExtractROIType
::
New
();
extract
->
SetInput
(
changeLabelFilter
->
GetOutput
());
std
::
cout
<<
parseResult
->
GetParameterUInt
(
"ROIStartX"
)
<<
", "
<<
parseResult
->
GetParameterUInt
(
"ROIStartY"
)
<<
", "
<<
parseResult
->
GetParameterUInt
(
"ROISizeX"
)
<<
", "
<<
parseResult
->
GetParameterUInt
(
"ROISizeY"
)
<<
std
::
endl
;
extract
->
SetStartX
((
unsigned
long
)
parseResult
->
GetParameterUInt
(
"ROIStartX"
));
extract
->
SetStartY
((
unsigned
long
)
parseResult
->
GetParameterUInt
(
"ROIStartY"
));
extract
->
SetSizeX
((
unsigned
long
)
parseResult
->
GetParameterUInt
(
"ROISizeX"
));
extract
->
SetSizeY
((
unsigned
long
)
parseResult
->
GetParameterUInt
(
"ROISizeY"
));
extract
->
Update
();
writer
->
SetInput
(
extract
->
GetOutput
());
}
else
{
writer
->
SetInput
(
changeLabelFilter
->
GetOutput
());
}
writer
->
Update
();
std
::
cout
<<
"Classification done ... "
<<
std
::
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment