OTB  9.0.0
Orfeo Toolbox
otbLabelMapToAttributeImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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
otbAttributesMapLabelObject.h
otb::LabelMapToAttributeImageFilter::AttributeAccessorType
TAttributeAccessor AttributeAccessorType
Definition: otbLabelMapToAttributeImageFilter.h:72
otb::LabelMapToAttributeImageFilter::AttributesMapType
LabelObjectType::AttributesMapType AttributesMapType
Definition: otbLabelMapToAttributeImageFilter.h:63
otb::LabelMapToAttributeImageFilter::GetChosenAttributes
const AttributeListType & GetChosenAttributes()
Definition: otbLabelMapToAttributeImageFilter.h:82
otb::LabelMapToAttributeImageFilter::VectorPixelType
itk::VariableLengthVector< OutputInternalPixelType > VectorPixelType
Definition: otbLabelMapToAttributeImageFilter.h:69
otb::LabelMapToAttributeImageFilter::InputImageType
TInputImage InputImageType
Definition: otbLabelMapToAttributeImageFilter.h:57
otb::LabelMapToAttributeImageFilter::AttributeListType
std::vector< std::string > AttributeListType
Definition: otbLabelMapToAttributeImageFilter.h:71
otb::LabelMapToAttributeImageFilter
This class produces an image from attributes in a label map.
Definition: otbLabelMapToAttributeImageFilter.h:44
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LabelMapToAttributeImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbLabelMapToAttributeImageFilter.h:65
otbLabelMapToAttributeImageFilter.hxx
otb::LabelMapToAttributeImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbLabelMapToAttributeImageFilter.h:51
otb::LabelMapToAttributeImageFilter::m_BackgroundValue
OutputInternalPixelType m_BackgroundValue
Definition: otbLabelMapToAttributeImageFilter.h:114
otb::LabelMapToAttributeImageFilter::SetAttributeForNthChannel
bool SetAttributeForNthChannel(unsigned int channel, const std::string &attribute)
Definition: otbLabelMapToAttributeImageFilter.h:97
otb::LabelMapToAttributeImageFilter::ConstLineIteratorType
LabelObjectType::ConstLineIterator ConstLineIteratorType
Definition: otbLabelMapToAttributeImageFilter.h:62
otb::LabelMapToAttributeImageFilter::~LabelMapToAttributeImageFilter
~LabelMapToAttributeImageFilter() override
Definition: otbLabelMapToAttributeImageFilter.h:104
otb::LabelMapToAttributeImageFilter::AttributeValueType
AttributeAccessorType::AttributeValueType AttributeValueType
Definition: otbLabelMapToAttributeImageFilter.h:73
otb::LabelMapToAttributeImageFilter::m_ChosenAttributes
AttributeListType m_ChosenAttributes
Definition: otbLabelMapToAttributeImageFilter.h:117
otb::LabelMapToAttributeImageFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbLabelMapToAttributeImageFilter.h:66
otb::LabelMapToAttributeImageFilter::LabelObjectType
InputImageType::LabelObjectType LabelObjectType
Definition: otbLabelMapToAttributeImageFilter.h:61
otb::LabelMapToAttributeImageFilter::OutputInternalPixelType
OutputImageType::InternalPixelType OutputInternalPixelType
Definition: otbLabelMapToAttributeImageFilter.h:67
otb::LabelMapToAttributeImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbLabelMapToAttributeImageFilter.h:50
otb::LabelMapToAttributeImageFilter::Self
LabelMapToAttributeImageFilter Self
Definition: otbLabelMapToAttributeImageFilter.h:48
otb::LabelMapToAttributeImageFilter::IndexType
OutputImageType::IndexType IndexType
Definition: otbLabelMapToAttributeImageFilter.h:68
otb::LabelMapToAttributeImageFilter::Superclass
itk::LabelMapFilter< TInputImage, TOutputImage > Superclass
Definition: otbLabelMapToAttributeImageFilter.h:49