OTB  6.7.0
Orfeo Toolbox
otbGeodesicMorphologyLevelingFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbGeodesicMorphologyLevelingFilter_h
22 #define otbGeodesicMorphologyLevelingFilter_h
23 
24 #include "otbFunctorImageFilter.h"
25 
26 namespace otb
27 {
28 namespace Functor
29 {
30 namespace LevelingFunctor_tags
31 {
32 struct pixel {};
33 struct convex_pixel {};
34 struct concave_pixel {};
35 }
47 template <class TInput, class TInputMap, class TOutput>
49 {
50 public:
54  virtual ~LevelingFunctor() {}
55 
56  inline TOutput operator ()(const TInput& pixel, const TInputMap& convexPixel, const TInputMap& concavePixel) const
57  {
58  TOutput result;
59 
60  if (convexPixel > concavePixel)
61  {
62  result = static_cast<TOutput>(pixel - convexPixel);
63  }
64  else if (convexPixel < concavePixel)
65  {
66  result = static_cast<TOutput>(concavePixel + pixel);
67  }
68  else
69  {
70  result = static_cast<TOutput>(pixel);
71  }
72  return result;
73  }
74 };
75 } // end namespace Functor
76 
89 template <class TInputImage, class TInputMaps, class TOutputImage>
90 using GeodesicMorphologyLevelingFilter = FunctorImageFilter
91  < Functor::LevelingFunctor<typename TInputImage::PixelType,
92  typename TInputMaps::PixelType,
93  typename TOutputImage::PixelType>,
94  std::tuple<typename Functor::LevelingFunctor_tags::pixel,
95  typename Functor::LevelingFunctor_tags::convex_pixel,
97 } // End namespace otb
98 #endif
FunctorImageFilter< Functor::LevelingFunctor< typename TInputImage::PixelType, typename TInputMaps::PixelType, typename TOutputImage::PixelType >, std::tuple< typename Functor::LevelingFunctor_tags::pixel, typename Functor::LevelingFunctor_tags::convex_pixel, typename Functor::LevelingFunctor_tags::concave_pixel > > GeodesicMorphologyLevelingFilter
This filter performs the leveling operation defined in the documentation of the geodesic decompositio...
TOutput operator()(const TInput &pixel, const TInputMap &convexPixel, const TInputMap &concavePixel) const
This functor performs the pixel-wise leveling operation needed in the geodesic morphology decompositi...