OTB  10.0.0
Orfeo Toolbox
otbBandsStatisticsAttributesLabelMapFilter.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 
21 #ifndef otbBandsStatisticsAttributesLabelMapFilter_h
22 #define otbBandsStatisticsAttributesLabelMapFilter_h
23 
26 
27 namespace otb
28 {
29 namespace Functor
30 {
50 template <class TLabelObject, class TFeatureImage>
52 {
53 public:
54  // Self typedef
56 
58  typedef typename TFeatureImage::PixelType FeatureType;
59 
61  typedef TLabelObject LabelObjectType;
62 
64  typedef typename TFeatureImage::ConstPointer FeatureImageConstPointer;
65 
68 
70  typedef std::map<std::string, StatsFunctorType> StatsFunctorsMapType;
71 
74 
77 
79  bool operator!=(const Self& self);
80  bool operator==(const Self& self);
82 
86  inline void operator()(LabelObjectType* lo) const;
87 
89  void AddFeature(const std::string& name, const TFeatureImage* img);
90 
92  bool RemoveFeature(const std::string& name);
93 
95  const TFeatureImage* GetFeatureImage(const std::string& name) const;
96 
98  void ClearAllFeatures();
99 
101  unsigned int GetNumberOfFeatures() const;
102 
104  void SetReducedAttributeSet(bool flag);
105 
107  bool GetReducedAttributeSet() const;
108 
109 private:
112 
115 };
116 } // End namespace Functor
117 
138 template <class TImage, class TFeatureImage>
141  TImage, typename Functor::BandStatsAttributesLabelObjectFunctor<typename TImage::LabelObjectType, otb::Image<double, 2>>>
142 {
143 public:
145  typedef TImage ImageType;
146  typedef typename ImageType::RegionType InputImageRegionType;
147  typedef typename ImageType::LabelObjectType LabelObjectType;
148  typedef TFeatureImage FeatureImageType;
149  typedef typename FeatureImageType::InternalPixelType FeatureInternalPixelType;
150  typedef double InternalPrecisionType;
152 
155 
159  typedef itk::SmartPointer<Self> Pointer;
160  typedef itk::SmartPointer<const Self> ConstPointer;
161  typedef typename ImageType::Pointer ImagePointer;
162 
164  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
165 
167  itkNewMacro(Self);
168 
171 
173  void SetFeatureImage(const TFeatureImage* input);
174 
176  const FeatureImageType* GetFeatureImage() const;
177 
179  void SetReducedAttributeSet(bool flag);
180 
182  bool GetReducedAttributeSet() const;
183 
184  itkBooleanMacro(ReducedAttributeSet);
185 
186 protected:
189 
192  {
193  }
194 
195  void AllocateOutputs() override;
196 
197  void GenerateInputRequestedRegion() override;
198 
199  void EnlargeOutputRequestedRegion(itk::DataObject*) override{};
200 
202  void BeforeThreadedGenerateData() override;
203 
205  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
206 
207 private:
209  void operator=(const Self&) = delete;
210 
211 }; // end of class
212 
213 } // end namespace itk
214 
215 #ifndef OTB_MANUAL_INSTANTIATION
217 #endif
218 
219 #endif
This filter computes band statistics attributes for each object.
Functor::BandStatsAttributesLabelObjectFunctor< LabelObjectType, InternalImageType > FunctorType
BandsStatisticsAttributesLabelMapFilter(const Self &)=delete
LabelMapFeaturesFunctorImageFilter< ImageType, FunctorType > Superclass
StatisticsAttributesLabelObjectFunctor< TLabelObject, TFeatureImage > StatsFunctorType
Statistics functor.
TFeatureImage::PixelType FeatureType
Typedef of the feature image type.
const TFeatureImage * GetFeatureImage(const std::string &name) const
TFeatureImage::ConstPointer FeatureImageConstPointer
Feature image const pointer.
std::map< std::string, StatsFunctorType > StatsFunctorsMapType
Map to store the functors.
void AddFeature(const std::string &name, const TFeatureImage *img)
bool operator==(const Self &self)
True to compute only a reduced attribute set.
bool m_ReducedAttributeSet
True to compute only a reduced attribute set.
Functor to compute statistics attributes of one LabelObject.
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:92
This class applies a functor to compute new features.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.