OTB  6.7.0
Orfeo Toolbox
otbLocalGradientVectorImageFilter.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 otbLocalGradientVectorImageFilter_h
22 #define otbLocalGradientVectorImageFilter_h
23 
25 
26 #include <itkNumericTraits.h>
27 
28 namespace otb
29 {
30 
31 namespace Functor
32 {
38 template < class TInput, class TOutput >
40 {
41 public:
43  virtual ~LocalGradientOperator() { }
44 
45  TOutput operator() ( const TInput & input )
46  {
47  /*
48  * it is assumed that input and output have the same size
49  */
50  unsigned int length = input.GetPixel(0).Size();
51  TOutput output ( length );
52  for ( unsigned int i = 0; i < length; ++i )
53  {
54  output[i] = static_cast<typename TOutput::ValueType>(
55  input.GetCenterPixel()[i]
56  - input.GetPixel(5)[i] / 2.
57  - input.GetPixel(7)[i] / 2. );
58  }
59  return output;
60  }
61 }; // end of functor class
62 
63 } // end of namespace Functor
64 
70 template < class TInputImage, class TOutputImage >
72  : public UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage,
73  Functor::LocalGradientOperator<
74  typename itk::ConstNeighborhoodIterator<TInputImage>,
75  typename TOutputImage::PixelType > >
76 {
77 public:
80  typedef UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage,
83  typename TOutputImage::PixelType > > Superclass;
86 
88  itkNewMacro(Self);
89 
91  itkTypeMacro(LocalGradientVectorImageFilter, ImageToImageFilter);
92 
93 protected:
95  {
96  typename Superclass::RadiusType radius = {{1, 1}};
97  this->SetRadius( radius );
98  }
100 
101 private:
102  LocalGradientVectorImageFilter( const Self & ); // Not implemented
103  void operator=( const Self & ); // Not implemented
104 }; // end of class
105 
106 } // end of namespace otb
107 
108 
109 #endif // otbLocalGradientVectorImageFilter_h
Implements neighborhood-wise generic operation of one vector image.
Performs the calculation of LocalGradient derivation.
Implements the 3x3 Local Gradient to be processed on a vector image.
UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage, Functor::LocalGradientOperator< typename itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > > Superclass