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
b6f12eff
Commit
b6f12eff
authored
13 years ago
by
Julien Malik
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add PersistentImageToVectorDataFilter
parent
3f86887c
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
Code/Common/otbPersistentImageToVectorDataFilter.h
+114
-0
114 additions, 0 deletions
Code/Common/otbPersistentImageToVectorDataFilter.h
Code/Common/otbPersistentImageToVectorDataFilter.txx
+139
-0
139 additions, 0 deletions
Code/Common/otbPersistentImageToVectorDataFilter.txx
with
253 additions
and
0 deletions
Code/Common/otbPersistentImageToVectorDataFilter.h
0 → 100644
+
114
−
0
View file @
b6f12eff
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbPersistentImageToVectorDataFilter_h
#define __otbPersistentImageToVectorDataFilter_h
#include
"otbPersistentImageFilter.h"
#include
"itkExtractImageFilter.h"
#include
"otbConcatenateVectorDataFilter.h"
namespace
otb
{
/** \class PersistentImageToVectorDataFilter
* \brief Perform vectorization in a persistent way.
*
* This filter is a generic PersistentImageFilter, which encapsulate any filter
* which produces VectorData from an input Image.
*
* It provides a default implementation which merge
* the VectorData from the different tiles/strips used during streaming into
* a single VectorData, which can be accessed via GetVectorData()
*
* \sa PersistentImageFilter
*
*/
template
<
class
TImage
,
class
TOutputVectorData
>
class
ITK_EXPORT
PersistentImageToVectorDataFilter
:
public
PersistentImageFilter
<
TImage
,
TImage
>
{
public:
/** Standard Self typedef */
typedef
PersistentImageToVectorDataFilter
Self
;
typedef
PersistentImageFilter
<
TImage
,
TImage
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Runtime information support. */
itkTypeMacro
(
PersistentImageToVectorDataFilter
,
PersistentImageFilter
);
typedef
TImage
InputImageType
;
typedef
typename
InputImageType
::
Pointer
InputImagePointer
;
typedef
typename
InputImageType
::
RegionType
RegionType
;
typedef
typename
InputImageType
::
SizeType
SizeType
;
typedef
typename
InputImageType
::
IndexType
IndexType
;
typedef
typename
InputImageType
::
PixelType
PixelType
;
typedef
typename
InputImageType
::
InternalPixelType
InternalPixelType
;
typedef
TOutputVectorData
OutputVectorDataType
;
typedef
typename
TOutputVectorData
::
Pointer
OutputVectorDataPointerType
;
typedef
itk
::
ExtractImageFilter
<
InputImageType
,
InputImageType
>
ExtractImageFilterType
;
typedef
typename
ExtractImageFilterType
::
Pointer
ExtractImageFilterPointerType
;
typedef
otb
::
ConcatenateVectorDataFilter
<
OutputVectorDataType
>
ConcatenateVectorDataFilterType
;
typedef
typename
ConcatenateVectorDataFilterType
::
Pointer
ConcatenateVectorDataFilterPointerType
;
/** Smart Pointer type to a DataObject. */
typedef
itk
::
DataObject
::
Pointer
DataObjectPointer
;
OutputVectorDataType
*
GetOutputVectorData
()
const
;
/** Make a DataObjectof the correct type to be used as the specified
* output. */
virtual
DataObjectPointer
MakeOutput
(
unsigned
int
idx
);
void
AllocateOutputs
();
virtual
void
Reset
(
void
);
virtual
void
Synthetize
(
void
);
protected:
PersistentImageToVectorDataFilter
();
virtual
~
PersistentImageToVectorDataFilter
()
{}
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
virtual
void
GenerateData
();
ExtractImageFilterPointerType
m_ExtractFilter
;
private
:
PersistentImageToVectorDataFilter
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
virtual
OutputVectorDataPointerType
ProcessTile
(
const
InputImageType
*
inputImage
)
=
0
;
};
// end of class
}
// end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include
"otbPersistentImageToVectorDataFilter.txx"
#endif
#endif
This diff is collapsed.
Click to expand it.
Code/Common/otbPersistentImageToVectorDataFilter.txx
0 → 100644
+
139
−
0
View file @
b6f12eff
/*=========================================================================
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.
=========================================================================*/
#ifndef __otbPersistentImageToVectorDataFilter_txx
#define __otbPersistentImageToVectorDataFilter_txx
#include "otbPersistentImageToVectorDataFilter.h"
namespace otb
{
template<class TImage, class TOutputVectorData>
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::PersistentImageToVectorDataFilter()
{
this->itk::ProcessObject::SetNumberOfRequiredOutputs(2);
this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer());
m_ExtractFilter = ExtractImageFilterType::New();
}
template<class TImage, class TOutputVectorData>
typename PersistentImageToVectorDataFilter<TImage, TOutputVectorData>::DataObjectPointer
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::MakeOutput(unsigned int i)
{
if (i == 1)
{
return static_cast<itk::DataObject*>(OutputVectorDataType::New().GetPointer());
}
else
{
return Superclass::MakeOutput(i);
}
}
template<class TImage, class TOutputVectorData>
typename PersistentImageToVectorDataFilter<TImage, TOutputVectorData>::OutputVectorDataType *
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::GetOutputVectorData() const
{
return static_cast<OutputVectorDataType*>(const_cast<itk::DataObject*>(this->itk::ProcessObject::GetOutput(1)));
}
template<class TImage, class TOutputVectorData>
void
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::AllocateOutputs()
{
// Nothing that needs to be allocated for the outputs : the output is not meant to be used
//this->GetOutputVectorData()->Clear();
}
template<class TImage, class TOutputVectorData>
void
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::Reset()
{
typedef typename OutputVectorDataType::DataNodeType DataNodeType;
typedef typename DataNodeType::Pointer DataNodePointerType;
this->GetOutputVectorData()->Clear();
DataNodePointerType root = DataNodeType::New();
root->SetNodeId("Root");
this->GetOutputVectorData()->GetDataTree()->SetRoot(root);
DataNodePointerType folder = DataNodeType::New();
folder->SetNodeType(otb::FOLDER);
DataNodePointerType document = DataNodeType::New() ;
document->SetNodeType(otb::DOCUMENT);
this->GetOutputVectorData()->GetDataTree()->Add(folder, this->GetOutputVectorData()->GetDataTree()->GetRoot()->Get());
this->GetOutputVectorData()->GetDataTree()->Add(document , folder);
}
template<class TImage, class TOutputVectorData>
void
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::Synthetize()
{
}
template<class TImage, class TOutputVectorData>
void
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::GenerateData()
{
// make an extract to handle filter which request
// the largest possible region of their input
m_ExtractFilter = ExtractImageFilterType::New();
m_ExtractFilter->SetInput( this->GetInput() );
m_ExtractFilter->SetExtractionRegion( this->GetInput()->GetBufferedRegion() );
m_ExtractFilter->Update();
InputImagePointer image = m_ExtractFilter->GetOutput();
// call the processing function for this tile
OutputVectorDataPointerType vd = this->ProcessTile(image);
// merge the result into the output vector data object
OutputVectorDataPointerType output = GetOutputVectorData();
ConcatenateVectorDataFilterPointerType concatenate = ConcatenateVectorDataFilterType::New();
concatenate->AddInput(vd);
concatenate->AddInput(output);
concatenate->Update();
// copy metadata and reference the same data tree
output->Graft( concatenate->GetOutput() );
}
template<class TImage, class TOutputVectorData>
void
PersistentImageToVectorDataFilter<TImage, TOutputVectorData>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // end namespace otb
#endif
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