OTB  10.0.0
Orfeo Toolbox
otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbBinaryFunctorNeighborhoodJoinHistogramImageFilter_h
22 #define otbBinaryFunctorNeighborhoodJoinHistogramImageFilter_h
23 
24 #include "itkBinaryFunctorImageFilter.h"
25 #include "itkImageRegionIteratorWithIndex.h"
26 #include "itkConstNeighborhoodIterator.h"
27 #include "itkHistogram.h"
28 
29 namespace otb
30 {
31 
43 template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction>
44 class ITK_EXPORT BinaryFunctorNeighborhoodJoinHistogramImageFilter : public itk::ImageToImageFilter<TInputImage1, TOutputImage>
45 {
46 public:
49  typedef itk::ImageToImageFilter<TInputImage1, TOutputImage> Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
51  typedef itk::SmartPointer<const Self> ConstPointer;
52 
54  itkNewMacro(Self);
55 
57  itkTypeMacro(BinaryFunctorNeighborhoodJoinHistogramImageFilter, ImageToImageFilter);
58 
60  typedef TFunction FunctorType;
61  typedef TInputImage1 Input1ImageType;
62  typedef typename Input1ImageType::Pointer Input1ImagePointer;
63  typedef typename Input1ImageType::ConstPointer Input1ImageConstPointer;
64  typedef typename Input1ImageType::RegionType Input1ImageRegionType;
65  typedef typename Input1ImageType::PixelType Input1ImagePixelType;
66  typedef TInputImage2 Input2ImageType;
67  typedef typename Input2ImageType::Pointer Input2ImagePointer;
68  typedef typename Input2ImageType::ConstPointer Input2ImageConstPointer;
69  typedef typename Input2ImageType::RegionType Input2ImageRegionType;
70  typedef typename Input2ImageType::PixelType Input2ImagePixelType;
71  typedef TOutputImage OutputImageType;
72  typedef typename OutputImageType::Pointer OutputImagePointer;
73  typedef typename OutputImageType::RegionType OutputImageRegionType;
74  typedef typename OutputImageType::PixelType OutputImagePixelType;
75 
76  typedef itk::ProcessObject ProcessObjectType;
77 
78  typedef itk::ConstNeighborhoodIterator<TInputImage1> NeighborhoodIteratorType1;
79  typedef itk::ConstNeighborhoodIterator<TInputImage2> NeighborhoodIteratorType2;
80 
81  typedef typename NeighborhoodIteratorType1::RadiusType RadiusType1;
82  typedef typename NeighborhoodIteratorType2::RadiusType RadiusType2;
83 
84  typedef unsigned char RadiusSizeType;
85 
89  typedef typename itk::Statistics::Histogram<double, itk::Statistics::DenseFrequencyContainer2> HistogramType;
90  typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
91  typedef typename HistogramType::SizeType HistogramSizeType;
92 
94  void SetInput1(const TInputImage1* image1);
95 
97  void SetInput2(const TInputImage2* image2);
98 
100  const TInputImage1* GetInput1();
101  const TInputImage2* GetInput2();
103 
109  {
110  return m_Functor;
111  }
112 
119  void SetFunctor(const FunctorType& functor)
120  {
121  m_Functor = functor;
122  this->Modified();
123  }
125 
127  itkSetMacro(Radius, RadiusSizeType);
128 
131  itkSetMacro(UpperBoundIncreaseFactor, double);
132  itkGetMacro(UpperBoundIncreaseFactor, double);
134 
136  itkSetMacro(PaddingValue, Input1ImagePixelType);
137 
139  itkGetConstReferenceMacro(PaddingValue, Input1ImagePixelType);
140 
144  itkSetMacro(UsePaddingValue, bool);
145  itkGetMacro(UsePaddingValue, bool);
147 
148 protected:
151  {
152  }
153 
154  void BeforeThreadedGenerateData() override;
155 
166  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
167 
171  void GenerateInputRequestedRegion(void) override;
172 
174 
175  HistogramType::Pointer m_Histogram;
176 
177 private:
179  void operator=(const Self&) = delete;
180 
181  void ComputeHistogram();
182 
184 
187 
192 
195 };
196 
197 } // end namespace otb
198 
199 #ifndef OTB_MANUAL_INSTANTIATION
201 #endif
202 
203 #endif
BinaryFunctorNeighborhoodJoinHistogramImageFilter(const Self &)=delete
itk::Statistics::Histogram< double, itk::Statistics::DenseFrequencyContainer2 > HistogramType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.