OTB  6.7.0
Orfeo Toolbox
otbDSFusionOfClassifiersImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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>
70  public itk::ImageToImageFilter<TInputImage, TOutputImage>
71 {
72 public:
78 
80  itkNewMacro(Self);
81 
83  itkTypeMacro(DSFusionOfClassifiersImageFilter, ImageToImageFilter);
84 
85  // TInputImage is expected to be a vector image
86  typedef TInputImage InputImageType;
87  typedef typename InputImageType::ConstPointer InputImageConstPointerType;
88  typedef typename InputImageType::InternalPixelType ValueType;
89  typedef typename InputImageType::PixelType PixelType;
90  typedef typename InputImageType::InternalPixelType InternalPixelType;
91 
92  // TMaskImage is expected to be a mono band image
93  typedef TMaskImage MaskImageType;
94  typedef typename MaskImageType::ConstPointer MaskImageConstPointerType;
95  typedef typename MaskImageType::Pointer MaskImagePointerType;
96 
97  // TOutputImage is expected to be a mono band image
98  typedef TOutputImage OutputImageType;
99  typedef typename OutputImageType::Pointer OutputImagePointerType;
100  typedef typename OutputImageType::RegionType OutputImageRegionType;
101  typedef typename OutputImageType::PixelType LabelType;
102 
103  typedef double MassType;
104  typedef typename std::map<LabelType, MassType> LabelMassMapType;
105  typedef typename std::map<LabelType, unsigned int> ClassifierHistogramType;
106  typedef typename std::vector<LabelMassMapType> VectorOfMapOfMassesOfBeliefType;
107 
108 
110  itkSetMacro(LabelForNoDataPixels, LabelType);
111  itkGetMacro(LabelForNoDataPixels, LabelType);
113 
115  itkSetMacro(LabelForUndecidedPixels, LabelType);
116  itkGetMacro(LabelForUndecidedPixels, LabelType);
118 
119 
126  void SetInputMask(const MaskImageType * mask);
127 
128  void SetInputMapsOfMassesOfBelief(const VectorOfMapOfMassesOfBeliefType * ptrVectorOfMapOfMassesOfBelief);
129 
134  const MaskImageType * GetInputMask(void);
135 
136  const VectorOfMapOfMassesOfBeliefType * GetInputMapsOfMassesOfBelief(void);
137 
138  const LabelType OptimizedDSMassCombination(PixelType vectorPixelValue);
139 
140 
141 protected:
144 
147 
149  void GenerateOutputInformation() override;
150 
152  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
153 
155  void BeforeThreadedGenerateData() override;
156 
158  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
159 
160 private:
161  DSFusionOfClassifiersImageFilter(const Self &) = delete;
162  void operator =(const Self&) = delete;
163 
164  unsigned int m_NumberOfClassifiers;
167 
169  std::vector<MassType> m_VectorOfUniverseMOBs;
170 
173 
176 
177 };
178 } // End namespace otb
179 #ifndef OTB_MANUAL_INSTANTIATION
181 #endif
182 
183 #endif
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
unsigned int ThreadIdType
std::map< LabelType, unsigned int > ClassifierHistogramType
std::vector< LabelMassMapType > VectorOfMapOfMassesOfBeliefType
Performs a fusion of n classification maps using the Dempster Shafer (noted DS) rule of combination...