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
3f9d35a9
Commit
3f9d35a9
authored
13 years ago
by
Arnaud Jaen
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Add an example for class otbStreamingVectorizedSegmentation.
parent
7260c849
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
Examples/Segmentation/CMakeLists.txt
+2
-1
2 additions, 1 deletion
Examples/Segmentation/CMakeLists.txt
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
+137
-0
137 additions, 0 deletions
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
with
139 additions
and
1 deletion
Examples/Segmentation/CMakeLists.txt
+
2
−
1
View file @
3f9d35a9
...
...
@@ -125,7 +125,8 @@ TARGET_LINK_LIBRARIES(WatershedSegmentation OTBCommon OTBIO ITKAlgorithms ITKNum
#ITKBasicFilters ITKStatistics)
ADD_EXECUTABLE
(
StreamingMeanShiftSegmentation StreamingMeanShiftSegmentation.cxx
)
TARGET_LINK_LIBRARIES
(
StreamingMeanShiftSegmentation OTBCommon OTBIO OTBOBIA
)
IF
(
NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING
)
...
...
This diff is collapsed.
Click to expand it.
Examples/Segmentation/StreamingMeanShiftSegmentation.cxx
0 → 100644
+
137
−
0
View file @
3f9d35a9
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
Some parts of this code are derived from ITK. See ITKCopyright.txt
for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Software Guide : BeginLatex
//
// The following example illustrates how to segment images
// using the \doxygen{otb}{StreamingVectorizedSegmentation}.
// The \doxygen{otb}{MeanShiftImageFilter} is used to segment each tile of the image.
// The labeled output image of each tile is then polygonized and stored into a \doxygen{otb}{VectorData}
// The method used for polygonize is GDALPolygonize.
//
// First we include the segmentation filter (Here it is the MeanShiftFilter) and
// the StreamingVectorizedSegmentation header.
// Software Guide : EndLatex
#include
<iostream>
// Software Guide : BeginCodeSnippet
#include
"otbMeanShiftImageFilter.h"
#include
"otbStreamingVectorizedSegmentation.h"
// Software Guide : EndCodeSnippet
#include
"otbImage.h"
#include
"otbImageFileReader.h"
#include
"otbVectorDataFileWriter.h"
#include
"otbVectorData.h"
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
3
)
{
std
::
cerr
<<
"Missing Parameters "
<<
std
::
endl
;
std
::
cerr
<<
"Usage: "
<<
argv
[
0
];
std
::
cerr
<<
" inputImage outputVectorData nbLinePerStream "
<<
std
::
endl
;
return
1
;
}
// Software Guide : BeginLatex
//
// We now declare the image and pixel types to use as input of the MeanShiftFilter.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
float
InputPixelType
;
const
unsigned
int
Dimension
=
2
;
typedef
otb
::
Image
<
InputPixelType
,
Dimension
>
ImageType
;
typedef
otb
::
VectorData
<
double
,
2
>
VectorDataType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Next we declare the output VectorData type that will contain all the polygons.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
VectorData
<
double
,
2
>
VectorDataType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Then the mean shift segmentation filter is declared using the Image type declared previsouly.
// The StreamingVectorizedSegmentation is templated over the mean shift filter, the input image type and the output vector data type
// Software Guide : EndLatex
// Typedefs
// Software Guide : BeginCodeSnippet
typedef
otb
::
MeanShiftImageFilter
<
ImageType
,
ImageType
>
MeanShiftImageFilterType
;
typedef
otb
::
StreamingVectorizedSegmentation
<
ImageType
,
VectorDataType
,
MeanShiftImageFilterType
>
StreamingVectorizedSegmentationType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Finaly we define a Reader on the input image and a writer for the VectorData.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
WriterType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Now we have declared all type needed for the pipeline, we instanciate the different filters,
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
StreamingVectorizedSegmentationType
::
Pointer
filter
=
StreamingVectorizedSegmentationType
::
New
();
WriterType
::
Pointer
writer
=
WriterType
::
New
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// And we connect the pipeline and set parameters for the mean shift filter.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
reader
->
SetFileName
(
argv
[
1
]);
reader
->
GenerateOutputInformation
();
filter
->
SetInput
(
reader
->
GetOutput
());
//filter->GetStreamer()->SetNumberOfLinesStrippedStreaming(atoi(argv[3]));
filter
->
GetStreamer
()
->
SetAutomaticTiledStreaming
();
filter
->
GetSegmentationFilter
()
->
SetSpatialRadius
(
10
);
filter
->
GetSegmentationFilter
()
->
SetRangeRadius
(
15
);
filter
->
GetSegmentationFilter
()
->
SetMinimumRegionSize
(
400
);
filter
->
Update
();
writer
->
SetFileName
(
argv
[
2
]);
writer
->
SetInput
(
filter
->
GetOutputVectorData
());
writer
->
Update
();
// Software Guide : EndCodeSnippet
return
EXIT_SUCCESS
;
}
\ No newline at end of file
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