21 #ifndef otbFunctorImageFilter_h
22 #define otbFunctorImageFilter_h
27 #include "itkRGBPixel.h"
28 #include "itkRGBAPixel.h"
29 #include "itkFixedArray.h"
30 #include "itkDefaultConvertPixelTraits.h"
31 #include <type_traits>
32 #include "itkConstNeighborhoodIterator.h"
58 struct IsNeighborhood<const
itk::ConstNeighborhoodIterator<VectorImage<T>>&> : std::true_type
86 template <
class T,
unsigned int N>
114 static_assert(
IsSuitableType<T>::value,
"T can not be used as a template parameter for Image or VectorImage classes.");
122 static_assert(
IsSuitableType<T>::value,
"T can not be used as a template parameter for Image or VectorImage classes.");
130 static_assert(
IsSuitableType<T>::value,
"T can not be used as a template parameter for Image or VectorImage classes.");
157 template <
typename T>
158 using RemoveCVRef =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
168 template <
typename T>
171 static_assert(std::is_class<T>::value || std::is_function<T>::value,
"T is not a class or function");
172 using Type = decltype(&T::operator());
188 template <
typename T,
typename TNameMap>
193 namespace functor_filter_details
195 template <
typename R,
typename TNameMap,
typename... T>
202 template <
typename V>
217 template <
typename R,
typename... T,
typename TNameMap>
226 template <
typename C,
typename R,
typename... T,
typename TNameMap>
235 template <
typename C,
typename R,
typename... T,
typename TNameMap>
244 template <
typename R,
typename... T,
typename TNameMap>
253 template <
typename C,
typename R,
typename... T,
typename TNameMap>
262 template <
typename C,
typename R,
typename... T,
typename TNameMap>
297 template <
typename Functor,
typename TNameMap =
void>
321 template <
class TFunction,
class TNameMap =
void>
344 using Superclass::NumberOfInputs;
350 template <
typename F = TFunction>
351 static std::enable_if_t<std::is_default_constructible<F>::value,
Pointer>
New()
364 template <
typename F = TFunction>
365 static std::enable_if_t<!std::is_default_constructible<F>::value,
Pointer>
New()
367 static_assert(std::is_default_constructible<F>::value,
369 "function as the functor used for the filter creation is not default "
408 friend auto NewFunctorFilter<TFunction, TNameMap>(TFunction f, itk::Size<2> radius);
416 void GenerateInputRequestedRegion(
void)
override;
421 void GenerateOutputInformation()
override;
432 template <
typename Functor,
typename TNameMap>
436 using PointerType =
typename FilterType::Pointer;
438 PointerType p =
new FilterType(f, radius);
454 template <
typename F>
491 template <
typename Functor,
typename TNameMap =
void>
492 auto NewFunctorFilter(Functor f,
unsigned int numberOfOutputBands, itk::Size<2> radius = {{0, 0}})
494 using FunctorType = NumberOfOutputBandsDecorator<Functor>;
495 FunctorType decoratedF(f, numberOfOutputBands);
496 return NewFunctorFilter<FunctorType, TNameMap>(decoratedF, radius);
501 #ifndef OTB_MANUAL_INSTANTIATION
A generic functor filter templated by its functor.
FunctorImageFilter(const FunctorType &f, itk::Size< 2 > radius)
Constructor of functor filter, will copy the functor.
typename SuperclassHelper::InputHasNeighborhood InputHasNeighborhood
const FunctorType & GetFunctor() const
FunctorType & GetModifiableFunctor()
~FunctorImageFilter()=default
void operator=(const Self &)=delete
typename Superclass::OutputImageType OutputImageType
FunctorImageFilter(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
typename SuperclassHelper::FilterType Superclass
static std::enable_if_t<!std::is_default_constructible< F >::value, Pointer > New()
static std::enable_if_t< std::is_default_constructible< F >::value, Pointer > New()
typename Superclass::InputTypesTupleType InputTypesTupleType
typename Superclass::template InputImageType< I > InputImageType
typename OutputImageType::RegionType OutputImageRegionType
itk::SmartPointer< Self > Pointer
Creation of an "otb" image which contains metadata.
Creation of an "otb" vector image which contains metadata.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
auto NewFunctorFilter(Functor f, itk::Size< 2 > radius={{0, 0}})
This helper method builds a fully functional FunctorImageFilter from a functor instance.
typename std::remove_cv< typename std::remove_reference< T >::type >::type RemoveCVRef
that has std::remove_cvref)
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::OutputImageType OutputImageType
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::InputHasNeighborhood InputHasNeighborhood
typename functor_filter_details::FunctorFilterSuperclassHelperImpl< R, TNameMap, T... >::FilterType FilterType
Struct allowing to derive the superclass prototype for the FunctorImageFilter class.
Helper struct to derive ImageType from template parameter.
Struct testing if T is a neighborhood.
Helper struct to check if a type can be used as pixel type.
This struct allows forwarding the operator of template parameter, while adding number of output compo...
constexpr NumberOfOutputBandsDecorator(F t, unsigned int nbComp)
unsigned int m_NumberOfOutputBands
constexpr vcl_size_t OutputSize(...) const
itk::VariableLengthVector< T > PixelType
Helper struct to derive PixelType from template parameter.
Struct to retrieve the operator type.
decltype(&T::operator()) Type
std::tuple< typename IsNeighborhood< T >::type... > InputHasNeighborhood
typename std::conditional< std::is_void< TNameMap >::value, VariadicInputsImageFilter< OutputImageType, InputImageType< T >... >, VariadicNamedInputsImageFilter< OutputImageType, TNameMap, InputImageType< T >... > >::type FilterType
typename ImageTypeDeduction< R >::ImageType OutputImageType
typename ImageTypeDeduction< typename PixelTypeDeduction< RemoveCVRef< V > >::PixelType >::ImageType InputImageType