OTB  9.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-2022 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:
202  StatisticsAttributesLabelMapFilter(const Self&) = delete;
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
otb::StatisticsAttributesLabelMapFilter::Self
StatisticsAttributesLabelMapFilter Self
Definition: otbStatisticsAttributesLabelMapFilter.h:142
otb::Functor::StatisticsAttributesLabelObjectFunctor::~StatisticsAttributesLabelObjectFunctor
virtual ~StatisticsAttributesLabelObjectFunctor()
Definition: otbStatisticsAttributesLabelMapFilter.hxx:43
otb::Functor::StatisticsAttributesLabelObjectFunctor::Self
StatisticsAttributesLabelObjectFunctor Self
Definition: otbStatisticsAttributesLabelMapFilter.h:46
otb::Functor::StatisticsAttributesLabelObjectFunctor::m_FeatureName
std::string m_FeatureName
Definition: otbStatisticsAttributesLabelMapFilter.h:98
otbStatisticsAttributesLabelMapFilter.hxx
otb::StatisticsAttributesLabelMapFilter::LabelObjectType
ImageType::LabelObjectType LabelObjectType
Definition: otbStatisticsAttributesLabelMapFilter.h:135
otb::Functor::StatisticsAttributesLabelObjectFunctor::operator==
bool operator==(const Self &self)
Definition: otbStatisticsAttributesLabelMapFilter.hxx:62
otb::LabelMapFeaturesFunctorImageFilter
This class applies a functor to compute new features.
Definition: otbLabelMapFeaturesFunctorImageFilter.h:53
otb::Functor::StatisticsAttributesLabelObjectFunctor::GetFeatureName
const std::string & GetFeatureName() const
Definition: otbStatisticsAttributesLabelMapFilter.hxx:314
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::StatisticsAttributesLabelObjectFunctor::LabelObjectType
TLabelObject LabelObjectType
Typedef of the label object.
Definition: otbStatisticsAttributesLabelMapFilter.h:57
otb::StatisticsAttributesLabelMapFilter::ImageType
TImage ImageType
Definition: otbStatisticsAttributesLabelMapFilter.h:134
otb::Functor::StatisticsAttributesLabelObjectFunctor::FeatureType
TFeatureImage::PixelType FeatureType
Typedef of the feature image type.
Definition: otbStatisticsAttributesLabelMapFilter.h:54
otb::Functor::StatisticsAttributesLabelObjectFunctor::SetReducedAttributeSet
void SetReducedAttributeSet(bool flag)
Definition: otbStatisticsAttributesLabelMapFilter.hxx:335
otb::StatisticsAttributesLabelMapFilter::Superclass
LabelMapFeaturesFunctorImageFilter< ImageType, FunctorType > Superclass
Definition: otbStatisticsAttributesLabelMapFilter.h:143
otb::StatisticsAttributesLabelMapFilter::FunctorType
Functor::StatisticsAttributesLabelObjectFunctor< LabelObjectType, FeatureImageType > FunctorType
Definition: otbStatisticsAttributesLabelMapFilter.h:139
otb::Functor::StatisticsAttributesLabelObjectFunctor::m_ReducedAttributeSet
bool m_ReducedAttributeSet
Definition: otbStatisticsAttributesLabelMapFilter.h:104
otb::StatisticsAttributesLabelMapFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbStatisticsAttributesLabelMapFilter.h:144
otb::Functor::StatisticsAttributesLabelObjectFunctor::SetFeatureName
void SetFeatureName(const std::string &name)
Definition: otbStatisticsAttributesLabelMapFilter.hxx:307
otb::Functor::StatisticsAttributesLabelObjectFunctor::StatisticsAttributesLabelObjectFunctor
StatisticsAttributesLabelObjectFunctor()
Definition: otbStatisticsAttributesLabelMapFilter.hxx:36
otb::StatisticsAttributesLabelMapFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: otbStatisticsAttributesLabelMapFilter.h:136
otb::Functor::StatisticsAttributesLabelObjectFunctor::GetReducedAttributeSet
bool GetReducedAttributeSet() const
Definition: otbStatisticsAttributesLabelMapFilter.hxx:342
otb::Functor::StatisticsAttributesLabelObjectFunctor::SetFeatureImage
void SetFeatureImage(const TFeatureImage *img)
Definition: otbStatisticsAttributesLabelMapFilter.hxx:321
otb::Functor::StatisticsAttributesLabelObjectFunctor::operator!=
bool operator!=(const Self &self)
Definition: otbStatisticsAttributesLabelMapFilter.hxx:49
otb::Functor::StatisticsAttributesLabelObjectFunctor::VectorType
itk::Vector< double, TFeatureImage::ImageDimension > VectorType
Definition: otbStatisticsAttributesLabelMapFilter.h:51
otb::Functor::StatisticsAttributesLabelObjectFunctor::ConstLineIteratorType
LabelObjectType::ConstLineIterator ConstLineIteratorType
Definition: otbStatisticsAttributesLabelMapFilter.h:60
otb::Functor::StatisticsAttributesLabelObjectFunctor::m_FeatureImage
TFeatureImage::ConstPointer m_FeatureImage
Definition: otbStatisticsAttributesLabelMapFilter.h:101
otb::Functor::StatisticsAttributesLabelObjectFunctor::GetFeatureImage
const TFeatureImage * GetFeatureImage() const
Definition: otbStatisticsAttributesLabelMapFilter.hxx:328
otb::StatisticsAttributesLabelMapFilter
This class is a fork of itk::StasticsLabelMapFilter to support AttributesMapLabelObject.
Definition: otbStatisticsAttributesLabelMapFilter.h:128
otb::Functor::StatisticsAttributesLabelObjectFunctor::MatrixType
itk::Matrix< double, TFeatureImage::ImageDimension, TFeatureImage::ImageDimension > MatrixType
Definition: otbStatisticsAttributesLabelMapFilter.h:49
otbLabelMapFeaturesFunctorImageFilter.h
otb::Functor::StatisticsAttributesLabelObjectFunctor::operator()
void operator()(LabelObjectType *lo) const
Definition: otbStatisticsAttributesLabelMapFilter.hxx:72
otb::StatisticsAttributesLabelMapFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbStatisticsAttributesLabelMapFilter.h:145
otb::Functor::StatisticsAttributesLabelObjectFunctor
Functor to compute statistics attributes of one LabelObject.
Definition: otbStatisticsAttributesLabelMapFilter.h:42