OTB  9.0.0
Orfeo Toolbox
otbLocalActivityVectorImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 otbLocalActivityVectorImageFilter_h
22 #define otbLocalActivityVectorImageFilter_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  {
44  }
46  {
47  }
48 
49  TOutput operator()(const TInput& input)
50  {
51  /*
52  * it is assumed that input and output have the same size
53  */
54  typename TInput::PixelType centerPixel = input.GetCenterPixel();
55 
56  unsigned int neighborSize = input.Size();
57  unsigned int vectorSize = centerPixel.Size();
58 
59  if (neighborSize == 1)
60  return centerPixel;
61 
62  TOutput output(vectorSize);
63 
64  for (unsigned int i = 0; i < vectorSize; ++i)
65  {
66  typename TOutput::ValueType out = itk::NumericTraits<typename TOutput::ValueType>::Zero;
67  for (unsigned int j = 0; j < neighborSize / 2; ++j)
68  {
69  out += input.GetPixel(j)[i];
70  }
71  for (unsigned int j = neighborSize / 2 + 1; j < neighborSize; ++j)
72  {
73  out += input.GetPixel(j)[i];
74  }
75 
76  output[i] = centerPixel[i] - out / static_cast<double>(neighborSize - 1);
77  }
78 
79  return output;
80  }
81 }; // end of functor class
82 
83 } // end of namespace Functor
84 
90 template <class TInputImage, class TOutputImage>
93  TInputImage, TOutputImage, Functor::LocalActivityOperator<typename itk::ConstNeighborhoodIterator<TInputImage>, typename TOutputImage::PixelType>>
94 {
95 public:
99  TInputImage, TOutputImage, Functor::LocalActivityOperator<typename itk::ConstNeighborhoodIterator<TInputImage>, typename TOutputImage::PixelType>>
101  typedef itk::SmartPointer<Self> Pointer;
102  typedef itk::SmartPointer<const Self> ConstPointer;
103 
105  itkNewMacro(Self);
106 
108  itkTypeMacro(LocalActivityVectorImageFilter, ImageToImageFilter);
109 
110 protected:
112  {
113  }
115  {
116  }
117 
118 private:
119  LocalActivityVectorImageFilter(const Self&); // Not implemented
120  void operator=(const Self&); // Not implemented
121 }; // end of class
122 
123 } // end of namespace otb
124 
125 
126 #endif // otbLocalActivityVectorImageFilter_h
otb::Functor::LocalActivityOperator::LocalActivityOperator
LocalActivityOperator()
Definition: otbLocalActivityVectorImageFilter.h:42
otb::LocalActivityVectorImageFilter
Implements the LocalActivity Gradient to be processed on a vector image.
Definition: otbLocalActivityVectorImageFilter.h:91
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LocalActivityVectorImageFilter::LocalActivityVectorImageFilter
LocalActivityVectorImageFilter()
Definition: otbLocalActivityVectorImageFilter.h:111
otb::Functor::LocalActivityOperator::operator()
TOutput operator()(const TInput &input)
Definition: otbLocalActivityVectorImageFilter.h:49
otb::LocalActivityVectorImageFilter::Self
LocalActivityVectorImageFilter Self
Definition: otbLocalActivityVectorImageFilter.h:97
otb::Functor::LocalActivityOperator
Performs the calculation of LocalActivity derivation.
Definition: otbLocalActivityVectorImageFilter.h:39
otb::LocalActivityVectorImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLocalActivityVectorImageFilter.h:102
otb::LocalActivityVectorImageFilter::~LocalActivityVectorImageFilter
~LocalActivityVectorImageFilter() override
Definition: otbLocalActivityVectorImageFilter.h:114
otb::UnaryFunctorNeighborhoodVectorImageFilter
Implements neighborhood-wise generic operation of one vector image.
Definition: otbUnaryFunctorNeighborhoodVectorImageFilter.h:42
otbUnaryFunctorNeighborhoodVectorImageFilter.h
otb::LocalActivityVectorImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLocalActivityVectorImageFilter.h:101
otb::Functor::LocalActivityOperator::~LocalActivityOperator
virtual ~LocalActivityOperator()
Definition: otbLocalActivityVectorImageFilter.h:45
otb::LocalActivityVectorImageFilter::Superclass
UnaryFunctorNeighborhoodVectorImageFilter< TInputImage, TOutputImage, Functor::LocalActivityOperator< typename itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > > Superclass
Definition: otbLocalActivityVectorImageFilter.h:100