OTB  6.7.0
Orfeo Toolbox
otbVerticalSobelVectorImageFilter.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 otbVerticalSobelVectorImageFilter_h
22 #define otbVerticalSobelVectorImageFilter_h
23 
25 
26 namespace otb
27 {
28 
29 namespace Functor
30 {
36 template < class TInput, class TOutput >
38 {
39 public:
41  virtual ~VerticalSobelOperator() { }
42 
43  TOutput operator() ( const TInput & input )
44  {
45  unsigned int length = input.GetPixel(0).Size();
46  TOutput output ( length );
47  for ( unsigned int i = 0; i < length; ++i )
48  {
49  output[i] = static_cast<typename TOutput::ValueType>(
50  ( input.GetPixel(0)[i] - input.GetPixel(6)[i] )
51  + 2 * ( input.GetPixel(1)[i] - input.GetPixel(7)[i] )
52  + ( input.GetPixel(2)[i] - input.GetPixel(8)[i] ) );
53  }
54  return output;
55  }
56 }; // end of functor class
57 
58 } // end of namespace Functor
59 
65 template < class TInputImage, class TOutputImage >
67  : public UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage,
68  Functor::VerticalSobelOperator<
69  typename itk::ConstNeighborhoodIterator<TInputImage>,
70  typename TOutputImage::PixelType > >
71 {
72 public:
75  typedef UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage,
78  typename TOutputImage::PixelType > > Superclass;
81 
83  itkNewMacro(Self);
84 
86  itkTypeMacro(VerticalSobelVectorImageFilter, ImageToImageFilter);
87 
88 protected:
90  {
91  typename Superclass::RadiusType radius = {{1, 1}};
92  this->SetRadius( radius );
93  }
95 
96 private:
97  VerticalSobelVectorImageFilter( const Self & ); // Not implemented
98  void operator=( const Self & ); // Not implemented
99 }; // end of class
100 
101 } // end of namespace otb
102 
103 
104 #endif // otbVerticalSobelVectorImageFilter_h
Performs the calculation of vertical Sobel derivation.
Implements neighborhood-wise generic operation of one vector image.
Implements the Vertical Sobel Gradient to be processed on a vector image.
UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage, Functor::VerticalSobelOperator< typename itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > > Superclass