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
4d4c1fb2
Commit
4d4c1fb2
authored
12 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Adapting example to API change
parent
f071aa24
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
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
+46
-15
46 additions, 15 deletions
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
with
46 additions
and
15 deletions
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
+
46
−
15
View file @
4d4c1fb2
...
...
@@ -23,7 +23,7 @@
// Software Guide : BeginLatex
//
// The following example illustrates how to segment very large images
// using the \doxygen{otb}{Streaming
Vectorized
Segmentation}. This filter is
// using the \doxygen{otb}{Streaming
ImageToOGRLayer
Segmentation
Filter
}. This filter is
// templated over the segmentation filter that will be used to segment each tile
// of the input image. In this example we will use the \doxygen{otb}{MeanShiftVectorImageFilter}.
// The labeled output image of each tile is then vectorized (using a filter based on GDALPolygonize)
...
...
@@ -37,7 +37,7 @@
#include
<iostream>
// Software Guide : BeginCodeSnippet
#include
"otbStreamingImageToOGR
DataSource
SegmentationFilter.h"
#include
"otbStreamingImageToOGR
Layer
SegmentationFilter.h"
#include
"otbMeanShiftVectorImageFilter.h"
#include
"otbOGRDataSourceWrapper.h"
#include
"otbOGRDataSourceStreamStitchingFilter.h"
...
...
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
// Software Guide : BeginCodeSnippet
//typedef otb::MeanShiftSmoothingImageFilter<ImageType, ImageType> MeanShiftImageFilterType;
typedef
otb
::
MeanShiftVectorImageFilter
<
ImageType
,
ImageType
,
LabelImageType
>
SegmentationFilterType
;
typedef
otb
::
StreamingImageToOGR
DataSource
SegmentationFilter
<
ImageType
,
SegmentationFilterType
>
StreamingVectorizedSegmentationType
;
typedef
otb
::
StreamingImageToOGR
Layer
SegmentationFilter
<
ImageType
,
SegmentationFilterType
>
StreamingVectorizedSegmentationType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
...
...
@@ -118,6 +118,12 @@ int main(int argc, char *argv[])
StreamingVectorizedSegmentationType
::
Pointer
filter
=
StreamingVectorizedSegmentationType
::
New
();
// Software Guide : EndCodeSnippet
reader
->
SetFileName
(
imageName
);
reader
->
UpdateOutputInformation
();
maskReader
->
SetFileName
(
maskName
);
maskReader
->
UpdateOutputInformation
();
// Software Guide : BeginLatex
//
// The instanciation of the DataSource is slightly different as usual.
...
...
@@ -131,7 +137,42 @@ int main(int argc, char *argv[])
// Software Guide : BeginCodeSnippet
otb
::
ogr
::
DataSource
::
Pointer
ogrDS
=
otb
::
ogr
::
DataSource
::
New
(
dataSourceName
,
otb
::
ogr
::
DataSource
::
Modes
::
write
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Next, we will create the layer inside the DataSource that will
// hold the polygons from the vectorized segmentation. First, we
// need to retrieve the spatial reference from the input image.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
OGRSpatialReference
oSRS
(
reader
->
GetOutput
()
->
GetProjectionRef
().
c_str
());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now, we can create the layer.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
otb
::
ogr
::
Layer
ogrLayer
=
ogrDS
->
CreateLayer
(
layerName
,
&
oSRS
,
wkbMultiPolygon
,
NULL
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Last, we need to create a field inside the layer that will hold
// the identifier of the polygons.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
OGRFieldDefn
ogrField
(
fieldName
.
c_str
(),
OFTInteger
);
ogrLayer
.
CreateField
(
ogrField
,
true
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now we set the parameters to the segmentation filter.The \doxygen{otb}{MeanShiftVectorImageFilter}
...
...
@@ -153,7 +194,6 @@ int main(int argc, char *argv[])
// \begin{itemize}
// \item tile size : use \code{SetTileDimensionTiledStreaming()} for square tile or \code{SetNumberOfLinesStrippedStreaming()}
// for Strip.
// \item layer name : name of the layer that will be created in the input \doxygen{otb}{ogr}{DataSource}.
// \item field name : name of the field that will contained the label values. (default is "DN").
// \item start label : first label. Each polygons have a unique label (incremented by one).
// \item option to filter small polygons (default to false).
...
...
@@ -164,7 +204,6 @@ int main(int argc, char *argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter
->
GetStreamer
()
->
SetTileDimensionTiledStreaming
(
tileSize
);
filter
->
SetLayerName
(
layerName
);
filter
->
SetFieldName
(
fieldName
);
filter
->
SetStartLabel
(
1
);
filter
->
SetFilterSmallObject
(
filterSmallObj
);
...
...
@@ -173,24 +212,16 @@ int main(int argc, char *argv[])
filter
->
SetSimplificationTolerance
(
tolerance
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Finally we connect the pipeline
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
reader
->
SetFileName
(
imageName
);
reader
->
UpdateOutputInformation
();
maskReader
->
SetFileName
(
maskName
);
maskReader
->
UpdateOutputInformation
();
// Software Guide : BeginCodeSnippet
filter
->
SetInput
(
reader
->
GetOutput
());
filter
->
SetInputMask
(
maskReader
->
GetOutput
());
filter
->
SetOGR
DataSource
(
ogrDS
);
filter
->
SetOGR
Layer
(
ogrLayer
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// And call the \code{Initialize()} method (needed to create the output layer in the datasource)
...
...
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