OTB  9.0.0
Orfeo Toolbox
otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.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 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 ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) 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
otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.hxx
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input1ImageType
TInputImage1 Input1ImageType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:61
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_Histogram
HistogramType::Pointer m_Histogram
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:175
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:51
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Self
BinaryFunctorNeighborhoodJoinHistogramImageFilter Self
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:48
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input2ImageConstPointer
Input2ImageType::ConstPointer Input2ImageConstPointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:68
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:73
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::ProcessObjectType
itk::ProcessObject ProcessObjectType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:76
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input2ImagePointer
Input2ImageType::Pointer Input2ImagePointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:67
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input2ImageType
TInputImage2 Input2ImageType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:66
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input1ImageConstPointer
Input1ImageType::ConstPointer Input1ImageConstPointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:63
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::NeighborhoodIteratorType1
itk::ConstNeighborhoodIterator< TInputImage1 > NeighborhoodIteratorType1
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:78
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:71
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:50
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:108
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:72
otb::Functor::JoinHistogramMI< itk::ConstNeighborhoodIterator< TInputImage1 >, itk::ConstNeighborhoodIterator< TInputImage2 >, TOutputImage::PixelType >
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:74
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter
Implements neighborhood-wise generic operation of two images.
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:44
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::MeasurementVectorType
HistogramType::MeasurementVectorType MeasurementVectorType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:90
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input1ImagePointer
Input1ImageType::Pointer Input1ImagePointer
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:62
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::FunctorType
TFunction FunctorType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:57
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_Functor
FunctorType m_Functor
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:183
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_UsePaddingValue
bool m_UsePaddingValue
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:191
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_UpperBoundIncreaseFactor
double m_UpperBoundIncreaseFactor
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:194
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input1ImagePixelType
Input1ImageType::PixelType Input1ImagePixelType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:65
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::HistogramSizeType
HistogramType::SizeType HistogramSizeType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:91
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input2ImageRegionType
Input2ImageType::RegionType Input2ImageRegionType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:69
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_Radius
RadiusSizeType m_Radius
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:173
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Superclass
itk::ImageToImageFilter< TInputImage1, TOutputImage > Superclass
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:49
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::SetFunctor
void SetFunctor(const FunctorType &functor)
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:119
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::RadiusType1
NeighborhoodIteratorType1::RadiusType RadiusType1
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:81
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::m_PaddingValue
Input1ImagePixelType m_PaddingValue
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:186
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::RadiusSizeType
unsigned char RadiusSizeType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:84
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::HistogramType
itk::Statistics::Histogram< double, itk::Statistics::DenseFrequencyContainer2 > HistogramType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:89
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::NeighborhoodIteratorType2
itk::ConstNeighborhoodIterator< TInputImage2 > NeighborhoodIteratorType2
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:79
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input2ImagePixelType
Input2ImageType::PixelType Input2ImagePixelType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:70
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::RadiusType2
NeighborhoodIteratorType2::RadiusType RadiusType2
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:82
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::~BinaryFunctorNeighborhoodJoinHistogramImageFilter
~BinaryFunctorNeighborhoodJoinHistogramImageFilter() override
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:150
otb::BinaryFunctorNeighborhoodJoinHistogramImageFilter::Input1ImageRegionType
Input1ImageType::RegionType Input1ImageRegionType
Definition: otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h:64