Orfeo Toolbox  4.2
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  offset1.Fill(0);
48  offset2.Fill(0);
49  int neighborhoodNumber;
50  if (itB.GetCenterPixel() > 0)
51  {
52  neighborhoodNumber = static_cast<int>(itB.GetCenterPixel() / (CONST_PI_4) -1);
53  }
54  else
55  {
56  neighborhoodNumber = static_cast<int>((itB.GetCenterPixel() + CONST_PI) / (CONST_PI_4) -1);
57  }
58  switch (neighborhoodNumber)
59  {
60  case 0:
61  offset1[0] = 1;
62  offset1[1] = -1;
63  offset2[0] = -1;
64  offset2[1] = 1;
65  break;
66  case 1:
67  offset1[0] = 1;
68  offset1[1] = 0;
69  offset2[0] = -1;
70  offset2[1] = 0;
71  break;
72  case 2:
73  offset1[0] = 1;
74  offset1[1] = 1;
75  offset2[0] = -1;
76  offset2[1] = -1;
77  break;
78  case 3:
79  offset1[0] = 0;
80  offset1[1] = 1;
81  offset2[0] = 0;
82  offset2[1] = -1;
83  break;
84  }
85  if ((itA.GetCenterPixel() > itA.GetPixel(offset1))
86  && (itA.GetCenterPixel() > itA.GetPixel(offset2)))
87  {
88  resp = itA.GetCenterPixel();
89  }
90  }
91  return resp;
92  }
93 };
94 }
102 template <class TInputModulus, class TInputDirection, class TOutputImage>
104  : public ModulusAndDirectionImageToImageFilter<TInputModulus, TInputDirection, TOutputImage>
105 {
106 public:
112 
114  itkNewMacro(Self);
115 
118 
124  typename TOutputImage::PixelType> FunctorType;
125  typedef otb::BinaryFunctorNeighborhoodImageFilter<TInputModulus, TInputDirection, TOutputImage,
127 
128 protected:
134  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const
135  {
136  Superclass::PrintSelf(os, indent);
137  }
139  virtual void GenerateData(void)
140  {
141  typename ComputingFilterType::Pointer filter = ComputingFilterType::New();
142  filter->SetInput1(this->GetInput());
143  filter->SetInput2(this->GetInputDirection());
144  filter->GraftOutput(this->GetOutput());
145  filter->Update();
146  this->GraftOutput(filter->GetOutput());
147  }
148 
149 private:
150  NonMaxRemovalByDirectionFilter(const Self &); //purposely not implemented
151  void operator =(const Self&); //purposely not implemented
152 };
153 } // End namespace otb
154 #endif

Generated at Sat Aug 30 2014 16:17:43 for Orfeo Toolbox with doxygen 1.8.3.1