OTB  9.0.0
Orfeo Toolbox
otbDSFusionOfClassifiersImageFilter.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 otbDSFusionOfClassifiersImageFilter_h
22 #define otbDSFusionOfClassifiersImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbVectorImage.h"
26 #include "otbImage.h"
27 
28 namespace otb
29 {
68 template <class TInputImage, class TOutputImage, class TMaskImage = TOutputImage>
69 class ITK_EXPORT DSFusionOfClassifiersImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
70 {
71 public:
74  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
75  typedef itk::SmartPointer<Self> Pointer;
76  typedef itk::SmartPointer<const Self> ConstPointer;
77 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(DSFusionOfClassifiersImageFilter, ImageToImageFilter);
83 
84  // TInputImage is expected to be a vector image
85  typedef TInputImage InputImageType;
86  typedef typename InputImageType::ConstPointer InputImageConstPointerType;
87  typedef typename InputImageType::InternalPixelType ValueType;
88  typedef typename InputImageType::PixelType PixelType;
89  typedef typename InputImageType::InternalPixelType InternalPixelType;
90 
91  // TMaskImage is expected to be a mono band image
92  typedef TMaskImage MaskImageType;
93  typedef typename MaskImageType::ConstPointer MaskImageConstPointerType;
94  typedef typename MaskImageType::Pointer MaskImagePointerType;
95 
96  // TOutputImage is expected to be a mono band image
97  typedef TOutputImage OutputImageType;
98  typedef typename OutputImageType::Pointer OutputImagePointerType;
99  typedef typename OutputImageType::RegionType OutputImageRegionType;
100  typedef typename OutputImageType::PixelType LabelType;
101 
102  typedef double MassType;
103  typedef typename std::map<LabelType, MassType> LabelMassMapType;
104  typedef typename std::map<LabelType, unsigned int> ClassifierHistogramType;
105  typedef typename std::vector<LabelMassMapType> VectorOfMapOfMassesOfBeliefType;
106 
107 
109  itkSetMacro(LabelForNoDataPixels, LabelType);
110  itkGetMacro(LabelForNoDataPixels, LabelType);
112 
114  itkSetMacro(LabelForUndecidedPixels, LabelType);
115  itkGetMacro(LabelForUndecidedPixels, LabelType);
117 
118 
125  void SetInputMask(const MaskImageType* mask);
126 
127  void SetInputMapsOfMassesOfBelief(const VectorOfMapOfMassesOfBeliefType* ptrVectorOfMapOfMassesOfBelief);
128 
133  const MaskImageType* GetInputMask(void);
134 
135  const VectorOfMapOfMassesOfBeliefType* GetInputMapsOfMassesOfBelief(void);
136 
137  const LabelType OptimizedDSMassCombination(PixelType vectorPixelValue);
138 
139 
140 protected:
143 
146  {
147  }
148 
150  void GenerateOutputInformation() override;
151 
153  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
154 
156  void BeforeThreadedGenerateData() override;
157 
159  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
160 
161 private:
162  DSFusionOfClassifiersImageFilter(const Self&) = delete;
163  void operator=(const Self&) = delete;
164 
165  unsigned int m_NumberOfClassifiers;
168 
170  std::vector<MassType> m_VectorOfUniverseMOBs;
171 
174 
177 };
178 } // End namespace otb
179 #ifndef OTB_MANUAL_INSTANTIATION
181 #endif
182 
183 #endif
otb::DSFusionOfClassifiersImageFilter::ValueType
InputImageType::InternalPixelType ValueType
Definition: otbDSFusionOfClassifiersImageFilter.h:87
otb::DSFusionOfClassifiersImageFilter::~DSFusionOfClassifiersImageFilter
~DSFusionOfClassifiersImageFilter() override
Definition: otbDSFusionOfClassifiersImageFilter.h:145
otb::DSFusionOfClassifiersImageFilter::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbDSFusionOfClassifiersImageFilter.h:98
otb::DSFusionOfClassifiersImageFilter::VectorOfMapOfMassesOfBeliefType
std::vector< LabelMassMapType > VectorOfMapOfMassesOfBeliefType
Definition: otbDSFusionOfClassifiersImageFilter.h:105
otbVectorImage.h
otb::DSFusionOfClassifiersImageFilter::LabelType
OutputImageType::PixelType LabelType
Definition: otbDSFusionOfClassifiersImageFilter.h:100
otbDSFusionOfClassifiersImageFilter.hxx
otbImage.h
otb::DSFusionOfClassifiersImageFilter::MaskImagePointerType
MaskImageType::Pointer MaskImagePointerType
Definition: otbDSFusionOfClassifiersImageFilter.h:94
otb::DSFusionOfClassifiersImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbDSFusionOfClassifiersImageFilter.h:99
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::DSFusionOfClassifiersImageFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbDSFusionOfClassifiersImageFilter.h:74
otb::DSFusionOfClassifiersImageFilter::InternalPixelType
InputImageType::InternalPixelType InternalPixelType
Definition: otbDSFusionOfClassifiersImageFilter.h:89
otb::DSFusionOfClassifiersImageFilter::PixelType
InputImageType::PixelType PixelType
Definition: otbDSFusionOfClassifiersImageFilter.h:88
otb::DSFusionOfClassifiersImageFilter
Performs a fusion of n classification maps using the Dempster Shafer (noted DS) rule of combination.
Definition: otbDSFusionOfClassifiersImageFilter.h:69
otb::DSFusionOfClassifiersImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbDSFusionOfClassifiersImageFilter.h:97
otb::DSFusionOfClassifiersImageFilter::m_VectorOfMapMOBs
VectorOfMapOfMassesOfBeliefType m_VectorOfMapMOBs
Definition: otbDSFusionOfClassifiersImageFilter.h:169
otb::DSFusionOfClassifiersImageFilter::m_NumberOfClassifiers
unsigned int m_NumberOfClassifiers
Definition: otbDSFusionOfClassifiersImageFilter.h:165
otb::DSFusionOfClassifiersImageFilter::InputImageType
TInputImage InputImageType
Definition: otbDSFusionOfClassifiersImageFilter.h:82
otb::DSFusionOfClassifiersImageFilter::InputImageConstPointerType
InputImageType::ConstPointer InputImageConstPointerType
Definition: otbDSFusionOfClassifiersImageFilter.h:86
otb::DSFusionOfClassifiersImageFilter::MassType
double MassType
Definition: otbDSFusionOfClassifiersImageFilter.h:102
otb::DSFusionOfClassifiersImageFilter::ClassifierHistogramType
std::map< LabelType, unsigned int > ClassifierHistogramType
Definition: otbDSFusionOfClassifiersImageFilter.h:104
otb::DSFusionOfClassifiersImageFilter::m_LabelForNoDataPixels
LabelType m_LabelForNoDataPixels
Definition: otbDSFusionOfClassifiersImageFilter.h:173
otb::DSFusionOfClassifiersImageFilter::m_Universe
ClassifierHistogramType m_Universe
Definition: otbDSFusionOfClassifiersImageFilter.h:166
otb::DSFusionOfClassifiersImageFilter::m_LabelForUndecidedPixels
LabelType m_LabelForUndecidedPixels
Definition: otbDSFusionOfClassifiersImageFilter.h:176
otb::DSFusionOfClassifiersImageFilter::Self
DSFusionOfClassifiersImageFilter Self
Definition: otbDSFusionOfClassifiersImageFilter.h:73
otb::DSFusionOfClassifiersImageFilter::m_VectorOfUniverseMOBs
std::vector< MassType > m_VectorOfUniverseMOBs
Definition: otbDSFusionOfClassifiersImageFilter.h:170
otb::DSFusionOfClassifiersImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbDSFusionOfClassifiersImageFilter.h:75
otb::DSFusionOfClassifiersImageFilter::LabelMassMapType
std::map< LabelType, MassType > LabelMassMapType
Definition: otbDSFusionOfClassifiersImageFilter.h:103
otb::DSFusionOfClassifiersImageFilter::m_NumberOfClassesInUniverse
unsigned int m_NumberOfClassesInUniverse
Definition: otbDSFusionOfClassifiersImageFilter.h:167
otb::DSFusionOfClassifiersImageFilter::MaskImageConstPointerType
MaskImageType::ConstPointer MaskImageConstPointerType
Definition: otbDSFusionOfClassifiersImageFilter.h:93
otb::DSFusionOfClassifiersImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbDSFusionOfClassifiersImageFilter.h:76
otb::DSFusionOfClassifiersImageFilter::MaskImageType
TMaskImage MaskImageType
Definition: otbDSFusionOfClassifiersImageFilter.h:92