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
Container registry
Model registry
Operate
Environments
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
Antoine Belvire
otb
Commits
d4ad1823
Commit
d4ad1823
authored
16 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
Exemple streaming explicite
parent
b832af83
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Examples/IO/CMakeLists.txt
+3
-0
3 additions, 0 deletions
Examples/IO/CMakeLists.txt
Examples/IO/ExplicitStreamingExample.cxx
+198
-0
198 additions, 0 deletions
Examples/IO/ExplicitStreamingExample.cxx
with
201 additions
and
0 deletions
Examples/IO/CMakeLists.txt
+
3
−
0
View file @
d4ad1823
...
...
@@ -6,6 +6,9 @@ TARGET_LINK_LIBRARIES(ImageReadWrite OTBCommon OTBIO ITKCommon ITKIO)
ADD_EXECUTABLE
(
StreamingImageReadWrite StreamingImageReadWrite.cxx
)
TARGET_LINK_LIBRARIES
(
StreamingImageReadWrite OTBCommon OTBIO ITKCommon ITKIO
)
ADD_EXECUTABLE
(
ExplicitStreamingExample ExplicitStreamingExample.cxx
)
TARGET_LINK_LIBRARIES
(
ExplicitStreamingExample OTBCommon OTBIO ITKCommon ITKIO
)
ADD_EXECUTABLE
(
ImageReadCastWrite ImageReadCastWrite.cxx
)
TARGET_LINK_LIBRARIES
(
ImageReadCastWrite OTBCommon OTBIO ITKCommon ITKIO
)
...
...
This diff is collapsed.
Click to expand it.
Examples/IO/ExplicitStreamingExample.cxx
0 → 100644
+
198
−
0
View file @
d4ad1823
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.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.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
#include
"otbVectorImage.h"
#include
"otbImageFileReader.h"
#include
"itkImageRegionConstIterator.h"
// Software Guide : BeginLatex
//
// Usually, the streaming process is hidden within the pipeline. This
// allows the user to get rid of the annoying task of splitting the
// images into tiles, end so on. However, for some kinds of
// processing, we do not really need a pipeline: no writer is needed,
// only read access to pixel values is wanted. In these cases, one
// has to explicitly set up the streaming procedure. Fortunately, OTB
// offers a high level of abstraction for this task. We will need to
// include the following header files:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include
"itkImageRegionSplitter.h"
#include
"otbStreamingTraits.h"
// Software Guide : EndCodeSnippet
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"Usage: "
<<
std
::
endl
;
std
::
cerr
<<
argv
[
0
]
<<
" inputImageFile nbLinesForStreaming "
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
infname
=
argv
[
1
];
const
unsigned
int
nbLinesForStreaming
=
atoi
(
argv
[
2
]);
typedef
float
PixelType
;
typedef
otb
::
VectorImage
<
PixelType
,
2
>
ImageType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ImageReaderType
;
// Software Guide : BeginLatex
//
// The \doxygen{otb}{StreamingTraits} class manages the streaming
// approaches which are possible with the image type over which it is
// templated. The class \doxygen{itk}{ImageRegionSplitter} is
// templated over the number of dimensions of the image and will
// perform the actual image splitting.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
StreamingTraits
<
ImageType
>
StreamingTraitsType
;
typedef
itk
::
ImageRegionSplitter
<
2
>
SplitterType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Once a region of the image is available, we will use classical
// region iterators to get the pixels.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
ImageType
::
RegionType
RegionType
;
typedef
itk
::
ImageRegionConstIterator
<
ImageType
>
IteratorType
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We instantiate the image file reader, but in order to avoid
// reading the whole image, we call the
// \code{GenerateOutputInformation()} method instead of the
// \code{Update()} one. \code{GenerateOutputInformation()} will make
// available the information about sizes, band, resolutions,
// etc. After that, we can access the largest possible region of the
// input image.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
ImageReaderType
::
Pointer
reader
=
ImageReaderType
::
New
();
reader
->
SetFileName
(
infname
);
reader
->
GenerateOutputInformation
();
RegionType
largestRegion
=
reader
->
GetOutput
()
->
GetLargestPossibleRegion
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We set up now the local streaming capabilities by asking the
// streaming traits to compute the number of regions to split the
// image into given the splitter, the user defined number of lines,
// and the input image information.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
SplitterType
::
Pointer
splitter
=
SplitterType
::
New
();
unsigned
int
numberOfStreamDivisions
=
StreamingTraitsType
::
CalculateNumberOfStreamDivisions
(
reader
->
GetOutput
(),
largestRegion
,
splitter
,
otb
::
SET_BUFFER_NUMBER_OF_LINES
,
0
,
0
,
nbLinesForStreaming
);
// Software Guide : EndCodeSnippet
std
::
cout
<<
"The images will be streamed into "
<<
numberOfStreamDivisions
<<
" parts."
<<
std
::
endl
;
// Software Guide : BeginLatex
//
// We can now get the split regions and iterate through them.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
unsigned
int
piece
=
0
;
RegionType
streamingRegion
;
for
(
piece
=
0
;
piece
<
numberOfStreamDivisions
;
piece
++
)
{
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We get the region
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
streamingRegion
=
splitter
->
GetSplit
(
piece
,
numberOfStreamDivisions
,
largestRegion
);
std
::
cout
<<
"Processing region: "
<<
streamingRegion
<<
std
::
endl
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We ask the reader to provide the region.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
reader
->
GetOutput
()
->
SetRequestedRegion
(
streamingRegion
);
reader
->
GetOutput
()
->
PropagateRequestedRegion
();
reader
->
GetOutput
()
->
UpdateOutputData
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We declare an iterator and walk through the region.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
IteratorType
it
(
reader
->
GetOutput
(),
streamingRegion
);
it
.
GoToBegin
();
while
(
!
it
.
IsAtEnd
())
{
std
::
cout
<<
it
.
Get
()
<<
std
::
endl
;
++
it
;
}
// Software Guide : EndCodeSnippet
}
return
EXIT_SUCCESS
;
}
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