OTB  10.0.0
Orfeo Toolbox
otbLabelMapToAttributeImageFilter.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 
22 #ifndef otbLabelMapToAttributeImageFilter_h
23 #define otbLabelMapToAttributeImageFilter_h
24 
25 #include "itkLabelMapFilter.h"
27 #include "itkVariableLengthVector.h"
28 
29 namespace otb
30 {
42 template <class TInputImage, class TOutputImage,
43  class TAttributeAccessor = typename Functor::AttributesMapLabelObjectAccessor<typename TInputImage::LabelObjectType>>
44 class ITK_EXPORT LabelMapToAttributeImageFilter : public itk::LabelMapFilter<TInputImage, TOutputImage>
45 {
46 public:
49  typedef itk::LabelMapFilter<TInputImage, TOutputImage> Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
51  typedef itk::SmartPointer<const Self> ConstPointer;
52 
54  itkNewMacro(Self);
55 
57  itkTypeMacro(LabelMapToAttributeImageFilter, LabelMapFilter);
58 
60  typedef TInputImage InputImageType;
61  typedef typename InputImageType::LabelObjectType LabelObjectType;
62  typedef typename LabelObjectType::ConstLineIterator ConstLineIteratorType;
63  typedef typename LabelObjectType::AttributesMapType AttributesMapType;
64 
65  typedef TOutputImage OutputImageType;
66  typedef typename OutputImageType::PixelType OutputPixelType;
67  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
68  typedef typename OutputImageType::IndexType IndexType;
69  typedef itk::VariableLengthVector<OutputInternalPixelType> VectorPixelType;
70 
71  typedef std::vector<std::string> AttributeListType;
72  typedef TAttributeAccessor AttributeAccessorType;
73  typedef typename AttributeAccessorType::AttributeValueType AttributeValueType;
74 
76  itkGetConstMacro(BackgroundValue, OutputInternalPixelType);
77 
79  itkSetMacro(BackgroundValue, OutputInternalPixelType);
80 
83  {
84  return m_ChosenAttributes;
85  }
86 
88  void SetChosenAttributes(AttributeListType& newAttributes);
89 
91  unsigned int GetNumberOfComponentsPerPixel();
92 
94  bool SetAttributeForNthChannel(unsigned int channel, const char* attribute);
95 
97  bool SetAttributeForNthChannel(unsigned int channel, const std::string& attribute)
98  {
99  return this->SetAttributeForNthChannel(channel, attribute.c_str());
100  }
101 
102 protected:
105 
106  void GenerateOutputInformation() override;
107 
108  void BeforeThreadedGenerateData() override;
109 
110  void ThreadedProcessLabelObject(LabelObjectType* labelObject) override;
111 
112 private:
115 
118 };
119 }
120 
121 #ifndef OTB_MANUAL_INSTANTIATION
123 #endif
124 
125 #endif
This class produces an image from attributes in a label map.
LabelObjectType::ConstLineIterator ConstLineIteratorType
OutputImageType::InternalPixelType OutputInternalPixelType
bool SetAttributeForNthChannel(unsigned int channel, const std::string &attribute)
itk::LabelMapFilter< TInputImage, TOutputImage > Superclass
LabelObjectType::AttributesMapType AttributesMapType
itk::VariableLengthVector< OutputInternalPixelType > VectorPixelType
AttributeAccessorType::AttributeValueType AttributeValueType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.