OTB  9.0.0
Orfeo Toolbox
otbNormalizeAttributesLabelMapFilter.hxx
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 otbNormalizeAttributesLabelMapFilter_hxx
23 #define otbNormalizeAttributesLabelMapFilter_hxx
24 
26 
27 namespace otb
28 {
29 
30 namespace Functor
31 {
32 
33 template <class TLabelObject>
35 {
36 }
37 
39 template <class TLabelObject>
41 {
42  bool resp = (m_Min != other.m_Min) || (m_Max != other.m_Max);
43  return resp;
44 }
46 
48 template <class TLabelObject>
50 {
51  return !(this != self);
52 }
53 
54 template <class TLabelObject>
56 {
57  const std::vector<std::string>& attr = lo->GetAvailableAttributes();
58 
59  std::vector<std::string>::const_iterator it;
60  for (it = attr.begin(); it != attr.end(); ++it)
61  {
62  const AttributesValueType& value = lo->GetAttribute((*it).c_str());
63  typename AttributesMapType::const_iterator minIt = m_Min.find(*it);
64  typename AttributesMapType::const_iterator maxIt = m_Max.find(*it);
65  if (minIt != m_Min.end() && maxIt != m_Max.end())
66  {
67  lo->SetAttribute((*it).c_str(), (value - minIt->second) / (maxIt->second - minIt->second));
68  }
69  }
70 }
71 
72 } // end namespace Functor
73 
74 template <class TImage>
75 void NormalizeAttributesLabelMapFilter<TImage>::PrintSelf(std::ostream& os, itk::Indent indent) const
76 {
77  Superclass::PrintSelf(os, indent);
78 }
79 
80 } // end namespace otb
81 #endif
otbNormalizeAttributesLabelMapFilter.h
otb::Functor::NormalizeAttributesLabelObjectFunctor::m_Max
AttributesMapType m_Max
Definition: otbNormalizeAttributesLabelMapFilter.h:86
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::NormalizeAttributesLabelObjectFunctor::operator()
void operator()(LabelObjectType *lo) const
Definition: otbNormalizeAttributesLabelMapFilter.hxx:55
otb::Functor::NormalizeAttributesLabelObjectFunctor::operator!=
bool operator!=(const Self &self)
Definition: otbNormalizeAttributesLabelMapFilter.hxx:40
otb::Functor::NormalizeAttributesLabelObjectFunctor< TImage::LabelObjectType >::AttributesValueType
LabelObjectType::AttributesValueType AttributesValueType
Definition: otbNormalizeAttributesLabelMapFilter.h:54
otb::Functor::NormalizeAttributesLabelObjectFunctor::m_Min
AttributesMapType m_Min
Definition: otbNormalizeAttributesLabelMapFilter.h:85
otb::Functor::NormalizeAttributesLabelObjectFunctor< TImage::LabelObjectType >::LabelObjectType
TImage::LabelObjectType LabelObjectType
Definition: otbNormalizeAttributesLabelMapFilter.h:52
otb::NormalizeAttributesLabelMapFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbNormalizeAttributesLabelMapFilter.hxx:75
otb::Functor::NormalizeAttributesLabelObjectFunctor::operator==
bool operator==(const Self &self)
Definition: otbNormalizeAttributesLabelMapFilter.hxx:49
otb::Functor::NormalizeAttributesLabelObjectFunctor::NormalizeAttributesLabelObjectFunctor
NormalizeAttributesLabelObjectFunctor()
Definition: otbNormalizeAttributesLabelMapFilter.hxx:34
otb::Functor::NormalizeAttributesLabelObjectFunctor
Functor to normalize all attributes of a LabelMap.
Definition: otbNormalizeAttributesLabelMapFilter.h:45