OTB  9.0.0
Orfeo Toolbox
otbAttributesMapOpeningLabelMapFilter.hxx
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 otbAttributesMapOpeningLabelMapFilter_hxx
23 #define otbAttributesMapOpeningLabelMapFilter_hxx
24 
26 
27 namespace otb
28 {
29 
30 template <class TImage>
32 {
33 }
34 
35 template <class TImage>
37 {
38 }
39 
40 
42 template <class TImage>
44 {
45  this->GetAccessor().SetAttributeName(name);
46 }
47 
49 template <class TImage>
51 {
52  return this->GetAccessor().GetAttributeName();
53 }
54 
55 
56 template <class TImage>
58 {
59  m_Accessor = accessor;
60  this->Modified();
61 }
62 
63 template <class TImage>
65 {
66  return m_Accessor;
67 }
68 
69 
70 template <class TImage>
72 {
73  // Allocate the output
74  this->AllocateOutputs();
75 
76  typename Superclass::ImageType* output = this->GetOutput();
77  typename Superclass::ImageType* output2 = this->GetOutput(1);
78 
79  // set the background value for the second output - this is not done in the superclasses
80  output2->SetBackgroundValue(output->GetBackgroundValue());
81 
82  // AttributeAccessorType accessor;
83 
84  itk::ProgressReporter progress(this, 0, output->GetNumberOfLabelObjects());
85 
86  typename Superclass::ImageType::Iterator it(output);
87  while (!it.IsAtEnd())
88  {
89  typename Superclass::LabelObjectType::LabelType label = it.GetLabel();
90  typename Superclass::LabelObjectType* labelObject = it.GetLabelObject();
91 
92  if ((!this->GetReverseOrdering() && m_Accessor(labelObject) < this->GetLambda()) ||
93  (this->GetReverseOrdering() && m_Accessor(labelObject) > this->GetLambda()))
94  {
95  // must increment the iterator before removing the object to avoid invalidating the iterator
96  ++it;
97  output2->AddLabelObject(labelObject);
98  output->RemoveLabel(label);
99  }
100  else
101  {
102  ++it;
103  }
104 
105  progress.CompletedPixel();
106  }
107 }
108 
109 
110 template <class TImage>
111 void AttributesMapOpeningLabelMapFilter<TImage>::PrintSelf(std::ostream& os, itk::Indent indent) const
112 {
113  Superclass::PrintSelf(os, indent);
114 }
115 
116 } // End namespace otb
117 
118 #endif
otb::AttributesMapOpeningLabelMapFilter::GenerateData
void GenerateData() override
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:71
otb::AttributesMapOpeningLabelMapFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:111
otb::AttributesMapOpeningLabelMapFilter::AttributeAccessorType
Superclass::AttributeAccessorType AttributeAccessorType
Definition: otbAttributesMapOpeningLabelMapFilter.h:54
otb::AttributesMapOpeningLabelMapFilter::GetAttributeName
const char * GetAttributeName()
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:50
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::AttributesMapOpeningLabelMapFilter::SetAttributeName
void SetAttributeName(const char *name)
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:43
otb::AttributesMapOpeningLabelMapFilter::GetAccessor
AttributeAccessorType & GetAccessor()
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:64
otb::AttributesMapOpeningLabelMapFilter::AttributesMapOpeningLabelMapFilter
AttributesMapOpeningLabelMapFilter()
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:31
otb::AttributesMapOpeningLabelMapFilter::SetAccessor
void SetAccessor(const AttributeAccessorType &accessor)
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:57
otb::AttributesMapOpeningLabelMapFilter::~AttributesMapOpeningLabelMapFilter
~AttributesMapOpeningLabelMapFilter() override
Definition: otbAttributesMapOpeningLabelMapFilter.hxx:36
otbAttributesMapOpeningLabelMapFilter.h