Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
8a214792
Commit
8a214792
authored
Oct 29, 2018
by
Julien Michel
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DOC: Enhance documentation
parent
f5f6bcf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
53 deletions
+49
-53
Modules/Filtering/ImageManipulation/include/otbFunctorImageFilter.h
...ltering/ImageManipulation/include/otbFunctorImageFilter.h
+49
-53
No files found.
Modules/Filtering/ImageManipulation/include/otbFunctorImageFilter.h
View file @
8a214792
...
...
@@ -110,46 +110,6 @@ template <class T> struct ImageTypeDeduction<const T &>
using
ImageType
=
typename
ImageTypeDeduction
<
T
>::
ImageType
;
};
/**
* \struct InputImageTraits
* \brief Struct allowing to derive input image types from operator()
* arguments
*
* Defines:
* - PixelType type to the underlying pixel type
* - ScalarType type to the underlying scalar type
* - ImageType type to the mocked up image type
*
* ImageType = Image<T> for T or itk::Neighborhood<T>
* ImageType = VectorImage<T> for itk::VariableLengthVector<T> or itk::Neighborhood<itk::VariableLengthVector<T>>
*/
template
<
typename
T
>
struct
InputImageTraits
{
using
ArgumentType
=
T
;
using
PixelType
=
typename
PixelTypeDeduction
<
T
>::
PixelType
;
using
ImageType
=
typename
ImageTypeDeduction
<
PixelType
>::
ImageType
;
};
/**
* \struct OutputImageTraits
* \brief Struct allowing to derive output image type from operator()
*
* Defines:
* - ScalarType type to the underlying scalar type
* - ImageType type to the mocked up image type
* - ImageType = Image<T> for T
* - ImageType = VectorImage<T> for itk::VariableLengthVector<T>
*/
template
<
typename
T
>
struct
OutputImageTraits
{
using
ResultType
=
T
;
using
ImageType
=
typename
ImageTypeDeduction
<
T
>::
ImageType
;
};
/**
* \struct FunctorFilterSuperclassHelper
* \brief Struct allowing to derive the superclass prototype for the
...
...
@@ -167,24 +127,24 @@ template <typename T> struct FunctorFilterSuperclassHelper : public FunctorFilte
/// Partial specialisation for R(*)(T...)
template
<
typename
R
,
typename
...
T
>
struct
FunctorFilterSuperclassHelper
<
R
(
*
)(
T
...)
>
{
using
OutputImageType
=
typename
OutputImageTraits
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
nputImageTraits
<
T
>::
ImageType
...
>
;
using
OutputImageType
=
typename
ImageTypeDeduction
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
mageTypeDeduction
<
typename
PixelTypeDeduction
<
T
>::
PixelType
>::
ImageType
...
>
;
using
InputHasNeighborhood
=
std
::
tuple
<
typename
IsNeighborhood
<
T
>::
ValueType
...
>
;
};
// Partial specialisation for R(C::*)(T...) const
template
<
typename
C
,
typename
R
,
typename
...
T
>
struct
FunctorFilterSuperclassHelper
<
R
(
C
::*
)(
T
...)
const
>
{
using
OutputImageType
=
typename
OutputImageTraits
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
nputImageTraits
<
T
>::
ImageType
...
>
;
using
OutputImageType
=
typename
ImageTypeDeduction
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
mageTypeDeduction
<
typename
PixelTypeDeduction
<
T
>::
PixelType
>::
ImageType
...
>
;
using
InputHasNeighborhood
=
std
::
tuple
<
typename
IsNeighborhood
<
T
>::
ValueType
...
>
;
};
// Partial specialisation for R(C::*)(T...)
template
<
typename
C
,
typename
R
,
typename
...
T
>
struct
FunctorFilterSuperclassHelper
<
R
(
C
::*
)(
T
...)
>
{
using
OutputImageType
=
typename
OutputImageTraits
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
nputImageTraits
<
T
>::
ImageType
...
>
;
using
OutputImageType
=
typename
ImageTypeDeduction
<
R
>::
ImageType
;
using
FilterType
=
VariadicInputsImageFilter
<
OutputImageType
,
typename
I
mageTypeDeduction
<
typename
PixelTypeDeduction
<
T
>::
PixelType
>::
ImageType
...
>
;
using
InputHasNeighborhood
=
std
::
tuple
<
typename
IsNeighborhood
<
T
>::
ValueType
...
>
;
};
...
...
@@ -217,10 +177,11 @@ template <typename Functor> auto NewFunctorFilter(const Functor& f, itk::Size<2>
/** \class FunctorImageFilter
* \brief TODO
*
* \brief A generic functor filter templated by its functor
*
* \sa VariadicInputsImageFilter
* \sa NewFunctorFilter
*
*
* \ingroup IntensityImageFilters Multithreaded Streamed
*
* \ingroup OTBImageManipulation
...
...
@@ -231,17 +192,21 @@ template <class TFunction>
{
public:
// Standard typedefs
using
Self
=
FunctorImageFilter
;
using
FunctorType
=
TFunction
;
using
Pointer
=
itk
::
SmartPointer
<
Self
>
;
using
ConstPointer
=
itk
::
SmartPointer
<
const
Self
>
;
// Superclass through the helper struct
using
Superclass
=
typename
FunctorFilterSuperclassHelper
<
TFunction
>::
FilterType
;
using
OutputImageType
=
typename
Superclass
::
OutputImageType
;
using
OutputImageRegionType
=
typename
OutputImageType
::
RegionType
;
using
ProcessObjectType
=
itk
::
ProcessObject
;
// A tuple of bool of the same size as the number of arguments in
// the functor
using
InputHasNeighborhood
=
typename
FunctorFilterSuperclassHelper
<
TFunction
>::
InputHasNeighborhood
;
/** Run-time type information (and related methods). */
...
...
@@ -286,7 +251,7 @@ private:
void
GenerateInputRequestedRegion
(
void
)
override
;
/**
* Will use the OutputSize() method
if
* Will use the OutputSize() method
of the functor if output is VectorImage
*/
void
GenerateOutputInformation
()
override
;
...
...
@@ -298,6 +263,7 @@ private:
itk
::
Size
<
2
>
m_Radius
;
};
// Actual implementation of NewFunctorFilter free function
template
<
typename
Functor
>
auto
NewFunctorFilter
(
const
Functor
&
f
,
itk
::
Size
<
2
>
radius
)
{
using
FilterType
=
FunctorImageFilter
<
Functor
>
;
...
...
@@ -308,22 +274,52 @@ template <typename Functor> auto NewFunctorFilter(const Functor& f, itk::Size<2>
return
p
;
}
/**
* \struct NumberOfOutputBandsDecorator
* \brief This struct allows to forward the operator of template
* parameter, while adding number of ouptut components service.
*
* Its purpose is to enable the use of lambda or functor witht
* Outputsize() method with FunctorImageFilter.
*
* It is used internally in NewFunctorFilter version with
* numberOfOutputBands parameter.
*/
template
<
typename
F
>
struct
NumberOfOutputBandsDecorator
:
F
{
public:
constexpr
NumberOfOutputBandsDecorator
(
const
F
t
,
unsigned
int
nbComp
)
:
F
(
t
),
m_NumberOfOutput
Component
s
(
nbComp
)
{}
constexpr
NumberOfOutputBandsDecorator
(
const
F
t
,
unsigned
int
nbComp
)
:
F
(
t
),
m_NumberOfOutput
Band
s
(
nbComp
)
{}
using
F
::
operator
();
constexpr
size_t
OutputSize
(...)
const
{
return
m_NumberOfOutput
Component
s
;
return
m_NumberOfOutput
Band
s
;
}
private:
unsigned
int
m_NumberOfOutput
Component
s
;
unsigned
int
m_NumberOfOutput
Band
s
;
};
/**
* brief This helper method builds a fully functional
* FunctorImageFilter from a functor instance which does not provide
* the OutputSize() service, or a lambda, returing a VariableLengthVector
*
* \param f the Functor to build the filter from
* \param numberOfOutputBands The number of output bands that
* this filter will return
* \param radius The size of neighborhood to use, if there is any
* itk::Neighborhood<T> in the operator() arguments.
* \return A ready to use OTB filter, which accepts n input image of
* type derived from the operator() arguments, and producing an image
* correpsonding to the operator() return type.
*
* Note that this function also works with a lambda as Functor,
* provided it returns a scalar type. If your lambda returns a
* VariableLengthVector, see the other NewFunctorFilter implementation.
*/
template
<
typename
Functor
>
auto
NewFunctorFilter
(
const
Functor
&
f
,
unsigned
int
numberOfOutputBands
,
itk
::
Size
<
2
>
radius
)
{
...
...
Julien Michel
@jmichel
mentioned in commit
ba576452
·
Nov 19, 2018
mentioned in commit
ba576452
mentioned in commit ba5764527a25d049ba6e9ab4074b930d1f00962c
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment