OTB  10.0.0
Orfeo Toolbox
otbImageDimensionalityReductionFilter.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 #ifndef otbImageDimensionalityReduction_h
21 #define otbImageDimensionalityReduction_h
22 
23 #include "itkImageToImageFilter.h"
25 #include "otbImage.h"
26 
27 namespace otb
28 {
41 template <class TInputImage, class TOutputImage, class TMaskImage = TOutputImage>
42 class ITK_EXPORT ImageDimensionalityReductionFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
43 {
44 public:
47  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
48  typedef itk::SmartPointer<Self> Pointer;
49  typedef itk::SmartPointer<const Self> ConstPointer;
50 
52  itkNewMacro(Self);
53 
55  itkTypeMacro(ImageDimensionalityReductionFilter, ImageToImageFilter);
56 
57  typedef TInputImage InputImageType;
58  typedef typename InputImageType::ConstPointer InputImageConstPointerType;
59  typedef typename InputImageType::InternalPixelType ValueType;
60 
61  typedef TMaskImage MaskImageType;
62  typedef typename MaskImageType::ConstPointer MaskImageConstPointerType;
63  typedef typename MaskImageType::Pointer MaskImagePointerType;
64 
65  typedef TOutputImage OutputImageType;
66  typedef typename OutputImageType::Pointer OutputImagePointerType;
67  typedef typename OutputImageType::RegionType OutputImageRegionType;
68  typedef typename OutputImageType::InternalPixelType LabelType;
69 
70  typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<LabelType>> ModelType;
72 
75 
77  itkSetObjectMacro(Model, ModelType);
80 
82  itkSetMacro(DefaultLabel, LabelType);
83  itkGetMacro(DefaultLabel, LabelType);
85 
87  itkSetMacro(UseConfidenceMap, bool);
88  itkGetMacro(UseConfidenceMap, bool);
90 
91  itkSetMacro(BatchMode, bool);
92  itkGetMacro(BatchMode, bool);
93  itkBooleanMacro(BatchMode);
94 
100  void SetInputMask(const MaskImageType* mask);
101 
106  const MaskImageType* GetInputMask(void);
107 
111  ConfidenceImageType* GetOutputConfidence(void);
112 
113 protected:
116 
119  {
120  }
121 
123  virtual void GenerateOutputInformation() override;
124 
126  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
127  void ClassicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
128  void BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId);
129 
131  void BeforeThreadedGenerateData() override;
132 
134  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
135 
136 private:
138  void operator=(const Self&) = delete;
139 
142 
145 
149 };
150 } // End namespace otb
151 #ifndef OTB_MANUAL_INSTANTIATION
153 #endif
154 
155 #endif
ImageDimensionalityReductionFilter(const Self &)=delete
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
MachineLearningModel< itk::VariableLengthVector< ValueType >, itk::VariableLengthVector< LabelType > > ModelType
void operator=(const Self &)=delete
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:92
itk::SmartPointer< Self > Pointer
Definition: otbImage.h:97
MachineLearningModel is the base class for all classifier objects (SVM, KNN, Random Forests,...
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.