OTB  6.7.0
Orfeo Toolbox
otbChangeLabelImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbChangeLabelImageFilter_hxx
22 #define otbChangeLabelImageFilter_hxx
23 
25 
26 namespace otb
27 {
28 
32 template <class TInputImage, class TOutputImage>
35  : m_NumberOfComponentsPerPixel(0)
36 {
37 }
38 
42 template <class TInputImage, class TOutputImage>
43 void
45 ::SetChange(const InputPixelType& original, const OutputPixelType& result)
46 {
47  OutputPixelType current = this->GetFunctor().GetChange(original);
48  if (current != result)
49  {
50  this->GetFunctor().SetChange(original, result);
51  this->Modified();
52  }
53 }
55 
59 template <class TInputImage, class TOutputImage>
60 void
62 ::SetChangeMap(const ChangeMapType& changeMap)
63 {
64  //If the whole map is being set then we assume that a real change is made
65  this->GetFunctor().SetChangeMap(changeMap);
66  this->Modified();
67 }
69 
73 template <class TInputImage, class TOutputImage>
74 void
77 {
78  //If the whole map is being set then we assume that a real change is made
79  this->GetFunctor().ClearChangeMap();
80  this->Modified();
81 }
83 
87 template <class TInputImage, class TOutputImage>
88 void
91 {
92  Superclass::GenerateOutputInformation();
93 
94  this->GetOutput()->SetNumberOfComponentsPerPixel(m_NumberOfComponentsPerPixel);
95 }
96 
100 template <class TInputImage, class TOutputImage>
101 void
103 ::PrintSelf(std::ostream& os, itk::Indent indent) const
104 {
105  Superclass::PrintSelf(os, indent);
106  os << indent << "Number of components per pixel: " << m_NumberOfComponentsPerPixel;
108 
109 }
110 
111 } // end namespace
112 
113 #endif
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void SetChangeMap(const ChangeMapType &changeMap)
void SetChange(const InputPixelType &original, const OutputPixelType &result)
TOutputImage::PixelType OutputPixelType
std::map< InputPixelType, OutputPixelType > ChangeMapType