OTB  10.0.0
Orfeo Toolbox
otbStatisticsAttributesLabelMapFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbStatisticsAttributesLabelMapFilter_h
23 #define otbStatisticsAttributesLabelMapFilter_h
24 
26 #include "itkMatrix.h"
27 #include "itkVector.h"
28 #include <string>
29 
30 namespace otb
31 {
32 namespace Functor
33 {
41 template <class TLabelObject, class TFeatureImage>
43 {
44 public:
45  // Self typedef
47 
48  // Matrix typedef
49  typedef typename itk::Matrix<double, TFeatureImage::ImageDimension, TFeatureImage::ImageDimension> MatrixType;
50  // Vector typedef
51  typedef typename itk::Vector<double, TFeatureImage::ImageDimension> VectorType;
52 
54  typedef typename TFeatureImage::PixelType FeatureType;
55 
57  typedef TLabelObject LabelObjectType;
58 
60  typedef typename LabelObjectType::ConstLineIterator ConstLineIteratorType;
61 
64 
67 
69  bool operator!=(const Self& self);
70  bool operator==(const Self& self);
72 
76  inline void operator()(LabelObjectType* lo) const;
77 
79  void SetFeatureName(const std::string& name);
80 
82  const std::string& GetFeatureName() const;
83 
85  void SetFeatureImage(const TFeatureImage* img);
86 
88  const TFeatureImage* GetFeatureImage() const;
89 
91  void SetReducedAttributeSet(bool flag);
92 
94  bool GetReducedAttributeSet() const;
95 
96 private:
97  // The name of the feature
98  std::string m_FeatureName;
99 
100  // The feature image
101  typename TFeatureImage::ConstPointer m_FeatureImage;
102 
103  // True to compute only a reduced attribute set
105 };
106 } // End namespace Functor
107 
127 template <class TImage, class TFeatureImage>
129  : public LabelMapFeaturesFunctorImageFilter<TImage,
130  typename Functor::StatisticsAttributesLabelObjectFunctor<typename TImage::LabelObjectType, TFeatureImage>>
131 {
132 public:
134  typedef TImage ImageType;
135  typedef typename ImageType::LabelObjectType LabelObjectType;
136  typedef TFeatureImage FeatureImageType;
137 
140 
144  typedef itk::SmartPointer<Self> Pointer;
145  typedef itk::SmartPointer<const Self> ConstPointer;
146 
148  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
149 
151  itkNewMacro(Self);
152 
155 
157  void SetFeatureImage(const TFeatureImage* input);
158 
160  const FeatureImageType* GetFeatureImage() const;
161 
163  void SetInput1(const TImage* input);
164 
166  const TImage* GetInput1() const;
167 
169  void SetInput2(const TFeatureImage* input);
170 
172  const TFeatureImage* GetInput2() const;
173 
175  void SetFeatureName(const std::string& name);
176 
178  const std::string& GetFeatureName() const;
179 
181  void SetReducedAttributeSet(bool flag);
182 
184  bool GetReducedAttributeSet() const;
185 
186  itkBooleanMacro(ReducedAttributeSet);
187 
188 protected:
191 
194 
196  void BeforeThreadedGenerateData() override;
197 
199  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
200 
201 private:
203  void operator=(const Self&) = delete;
204 }; // end of class
205 
206 } // end namespace otb
207 
208 #ifndef OTB_MANUAL_INSTANTIATION
210 #endif
211 
212 #endif
Functor to compute statistics attributes of one LabelObject.
itk::Matrix< double, TFeatureImage::ImageDimension, TFeatureImage::ImageDimension > MatrixType
itk::Vector< double, TFeatureImage::ImageDimension > VectorType
TFeatureImage::PixelType FeatureType
Typedef of the feature image type.
This class applies a functor to compute new features.
This class is a fork of itk::StasticsLabelMapFilter to support AttributesMapLabelObject.
StatisticsAttributesLabelMapFilter(const Self &)=delete
Functor::StatisticsAttributesLabelObjectFunctor< LabelObjectType, FeatureImageType > FunctorType
void operator=(const Self &)=delete
LabelMapFeaturesFunctorImageFilter< ImageType, FunctorType > Superclass
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.