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
ab8ac21e
Commit
ab8ac21e
authored
15 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add streaming capabilities to ImageToPointSetFilter
parent
fc4bcc4e
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
Code/BasicFilters/otbImageToPointSetFilter.h
+10
-0
10 additions, 0 deletions
Code/BasicFilters/otbImageToPointSetFilter.h
Code/BasicFilters/otbImageToPointSetFilter.txx
+65
-24
65 additions, 24 deletions
Code/BasicFilters/otbImageToPointSetFilter.txx
with
75 additions
and
24 deletions
Code/BasicFilters/otbImageToPointSetFilter.h
+
10
−
0
View file @
ab8ac21e
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#define __otbImageToPointSetFilter_h
#define __otbImageToPointSetFilter_h
#include
"otbPointSetSource.h"
#include
"otbPointSetSource.h"
#include
"itkImageRegionSplitter.h"
#include
"otbStreamingTraits.h"
namespace
otb
namespace
otb
{
{
...
@@ -51,6 +53,8 @@ public:
...
@@ -51,6 +53,8 @@ public:
typedef
typename
InputImageType
::
ConstPointer
InputImageConstPointer
;
typedef
typename
InputImageType
::
ConstPointer
InputImageConstPointer
;
typedef
typename
InputImageType
::
RegionType
InputImageRegionType
;
typedef
typename
InputImageType
::
RegionType
InputImageRegionType
;
typedef
typename
InputImageType
::
PixelType
InputImagePixelType
;
typedef
typename
InputImageType
::
PixelType
InputImagePixelType
;
itkStaticConstMacro
(
InputImageDimension
,
unsigned
int
,
TInputImage
::
ImageDimension
);
/** Some PointSet related typedefs. */
/** Some PointSet related typedefs. */
typedef
typename
Superclass
::
OutputPointSetType
OutputPointSetType
;
typedef
typename
Superclass
::
OutputPointSetType
OutputPointSetType
;
...
@@ -103,6 +107,12 @@ protected:
...
@@ -103,6 +107,12 @@ protected:
/** End Multi-threading implementation */
/** End Multi-threading implementation */
/** Setup for streaming */
typedef
StreamingTraits
<
InputImageType
>
StreamingTraitsType
;
typedef
itk
::
ImageRegionSplitter
<
itkGetStaticConstMacro
(
InputImageDimension
)
>
SplitterType
;
typedef
typename
SplitterType
::
Pointer
RegionSplitterPointer
;
RegionSplitterPointer
m_RegionSplitter
;
private
:
private
:
ImageToPointSetFilter
(
const
ImageToPointSetFilter
&
);
//purposely not implemented
ImageToPointSetFilter
(
const
ImageToPointSetFilter
&
);
//purposely not implemented
void
operator
=
(
const
ImageToPointSetFilter
&
);
//purposely not implemented
void
operator
=
(
const
ImageToPointSetFilter
&
);
//purposely not implemented
...
...
This diff is collapsed.
Click to expand it.
Code/BasicFilters/otbImageToPointSetFilter.txx
+
65
−
24
View file @
ab8ac21e
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "otbImageToPointSetFilter.h"
#include "otbImageToPointSetFilter.h"
namespace otb
namespace otb
{
{
...
@@ -39,6 +38,10 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
...
@@ -39,6 +38,10 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
ProcessObjectType::SetNumberOfRequiredOutputs(1);
ProcessObjectType::SetNumberOfRequiredOutputs(1);
ProcessObjectType::SetNthOutput(0, output.GetPointer());
ProcessObjectType::SetNthOutput(0, output.GetPointer());
// create default region splitter
m_RegionSplitter = itk::ImageRegionSplitter<itkGetStaticConstMacro(InputImageDimension)>::New();
}
}
/**
/**
...
@@ -128,31 +131,69 @@ void
...
@@ -128,31 +131,69 @@ void
ImageToPointSetFilter<TInputImage,TOutputPointSet>
ImageToPointSetFilter<TInputImage,TOutputPointSet>
::GenerateData(void)
::GenerateData(void)
{
{
// Call a method that can be overridden by a subclass to perform
// some calculations prior to splitting the main computations into
// separate threads
this->BeforeThreadedGenerateData();
// Set up the multithreaded processing
PointsContainerType * outputPointsContainer = this->GetOutput()->GetPoints();
ThreadStruct str;
outputPointsContainer->Initialize();
str.Filter = this;
typename TInputImage::RegionType inputRegion = this->GetInput()->GetLargestPossibleRegion();
unsigned int numDivisions;
numDivisions = StreamingTraitsType
::CalculateNumberOfStreamDivisions(this->GetInput(),
this->GetInput()->GetLargestPossibleRegion(),
m_RegionSplitter,
SET_AUTOMATIC_NUMBER_OF_STREAM_DIVISIONS,
0, 0, 0);
// Input is an image, cast away the constness so we can set
// the requested region.
InputImagePointer input = const_cast<TInputImage *> (this->GetInput());
/**
* Loop over the number of pieces, execute the upstream pipeline on each
* piece, and copy the results into the output image.
*/
unsigned int piece;
InputImageRegionType streamRegion;
for (piece = 0;
piece < numDivisions && !this->GetAbortGenerateData();
piece++)
{
streamRegion = m_RegionSplitter->GetSplit(piece, numDivisions, inputRegion);
typedef itk::ImageToImageFilterDetail::ImageRegionCopier<itkGetStaticConstMacro(InputImageDimension),
itkGetStaticConstMacro(InputImageDimension)> OutputToInputRegionCopierType;
OutputToInputRegionCopierType regionCopier;
InputImageRegionType inputRegion;
regionCopier(inputRegion, streamRegion);
input->SetRequestedRegion( inputRegion );
// Call a method that can be overridden by a subclass to perform
// some calculations prior to splitting the main computations into
// separate threads
this->BeforeThreadedGenerateData();
// Initializing object per thread
// Set up the multithreaded processing
typename PointsContainerType::Pointer defaultPointsContainer = PointsContainerType::New();
ThreadStruct str;
this->m_PointsContainerPerThread
str.Filter = this;
= OutputPointsContainerForThreadType(this->GetNumberOfThreads(),defaultPointsContainer);
// Initializing object per thread
typename PointsContainerType::Pointer defaultPointsContainer = PointsContainerType::New();
this->m_PointsContainerPerThread
= OutputPointsContainerForThreadType(this->GetNumberOfThreads(),defaultPointsContainer);
// Setting up multithreader
this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
this->GetMultiThreader()->SetSingleMethod(this->ThreaderCallback, &str);
// multithread the execution
// Setting up multithreader
this->GetMultiThreader()->SingleMethodExecute();
this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
this->GetMultiThreader()->SetSingleMethod(this->ThreaderCallback, &str);
// Call a method that can be overridden by a subclass to perform
// multithread the execution
// some calculations after all the threads have completed
this->GetMultiThreader()->SingleMethodExecute();
this->AfterThreadedGenerateData();
// Call a method that can be overridden by a subclass to perform
// some calculations after all the threads have completed
this->AfterThreadedGenerateData();
}
}
}
...
@@ -161,7 +202,7 @@ void
...
@@ -161,7 +202,7 @@ void
ImageToPointSetFilter<TInputImage,TOutputPointSet>
ImageToPointSetFilter<TInputImage,TOutputPointSet>
::BeforeThreadedGenerateData(void)
::BeforeThreadedGenerateData(void)
{
{
// this->AllocateOutputs();
}
}
template <class TInputImage, class TOutputPointSet>
template <class TInputImage, class TOutputPointSet>
...
@@ -171,7 +212,7 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
...
@@ -171,7 +212,7 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
{
{
// copy the lists to the output
// copy the lists to the output
PointsContainerType * outputPointsContainer = this->GetOutput()->GetPoints();
PointsContainerType * outputPointsContainer = this->GetOutput()->GetPoints();
outputPointsContainer->Initialize();
typedef typename PointsContainerType::ConstIterator OutputPointsContainerIterator;
typedef typename PointsContainerType::ConstIterator OutputPointsContainerIterator;
for (unsigned int i=0; i< this->m_PointsContainerPerThread.size(); ++i)
for (unsigned int i=0; i< this->m_PointsContainerPerThread.size(); ++i)
{
{
...
@@ -245,14 +286,14 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
...
@@ -245,14 +286,14 @@ ImageToPointSetFilter<TInputImage,TOutputPointSet>
// Get the output pointer
// Get the output pointer
typename InputImageType::ConstPointer inputPtr = this->GetInput();
typename InputImageType::ConstPointer inputPtr = this->GetInput();
const typename TInputImage::SizeType& requestedRegionSize
const typename TInputImage::SizeType& requestedRegionSize
= inputPtr->Get
LargestPossible
Region().GetSize();
= inputPtr->Get
Requested
Region().GetSize();
int splitAxis;
int splitAxis;
typename TInputImage::IndexType splitIndex;
typename TInputImage::IndexType splitIndex;
typename TInputImage::SizeType splitSize;
typename TInputImage::SizeType splitSize;
// Initialize the splitRegion to the output requested region
// Initialize the splitRegion to the output requested region
splitRegion = inputPtr->Get
LargestPossible
Region();
splitRegion = inputPtr->Get
Requested
Region();
splitIndex = splitRegion.GetIndex();
splitIndex = splitRegion.GetIndex();
splitSize = splitRegion.GetSize();
splitSize = splitRegion.GetSize();
...
...
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