Orfeo Toolbox  4.0
otbNonMaxRemovalByDirectionFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbNonMaxRemovalByDirectionFilter_h
19 #define __otbNonMaxRemovalByDirectionFilter_h
20 
23 
24 #include "otbMath.h"
25 
26 namespace otb
27 {
28 namespace Functor
29 {
35 template <class TInput1, class TInput2, class TOutput>
37 {
38 public:
41  inline TOutput operator ()(const TInput1& itA, const TInput2& itB)
42  {
43  TOutput resp = 0;
44  if (itA.GetCenterPixel() != 0)
45  {
46  typename TInput1::OffsetType offset1, offset2;
47  int neighborhoodNumber;
48  if (itB.GetCenterPixel() > 0)
49  {
50  neighborhoodNumber = static_cast<int>(itB.GetCenterPixel() / (CONST_PI_4) -1);
51  }
52  else
53  {
54  neighborhoodNumber = static_cast<int>((itB.GetCenterPixel() + CONST_PI) / (CONST_PI_4) -1);
55  }
56  switch (neighborhoodNumber)
57  {
58  case 0:
59  offset1[0] = 1;
60  offset1[1] = -1;
61  offset2[0] = -1;
62  offset2[1] = 1;
63  break;
64  case 1:
65  offset1[0] = 1;
66  offset1[1] = 0;
67  offset2[0] = -1;
68  offset2[1] = 0;
69  break;
70  case 2:
71  offset1[0] = 1;
72  offset1[1] = 1;
73  offset2[0] = -1;
74  offset2[1] = -1;
75  break;
76  case 3:
77  offset1[0] = 0;
78  offset1[1] = 1;
79  offset2[0] = 0;
80  offset2[1] = -1;
81  break;
82  }
83  if ((itA.GetCenterPixel() > itA.GetPixel(offset1))
84  && (itA.GetCenterPixel() > itA.GetPixel(offset2)))
85  {
86  resp = itA.GetCenterPixel();
87  }
88  }
89  return resp;
90  }
91 };
92 }
100 template <class TInputModulus, class TInputDirection, class TOutputImage>
102  : public ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage>
103 {
104 public:
110 
112  itkNewMacro(Self);
113 
116 
122  typename TOutputImage::PixelType> FunctorType;
123  typedef otb::BinaryFunctorNeighborhoodImageFilter<TInputModulus, TInputDirection, TOutputImage,
125 
126 protected:
132  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const
133  {
134  Superclass::PrintSelf(os, indent);
135  }
137  virtual void GenerateData(void)
138  {
139  typename ComputingFilterType::Pointer filter = ComputingFilterType::New();
140  filter->SetInput1(this->GetInput());
141  filter->SetInput2(this->GetInputDirection());
142  filter->GraftOutput(this->GetOutput());
143  filter->Update();
144  this->GraftOutput(filter->GetOutput());
145  }
146 
147 private:
148  NonMaxRemovalByDirectionFilter(const Self &); //purposely not implemented
149  void operator =(const Self&); //purposely not implemented
150 };
151 } // End namespace otb
152 #endif

Generated at Sat Mar 8 2014 16:11:30 for Orfeo Toolbox with doxygen 1.8.3.1