OTB  6.7.0
Orfeo Toolbox
otbClampImageFilter.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 
22 #ifndef otbClampImageFilter_hxx
23 #define otbClampImageFilter_hxx
24 
25 #include "otbClampImageFilter.h"
26 #include "itkImageRegionIterator.h"
27 #include "itkNumericTraits.h"
28 #include <limits>
29 #include "itkObjectFactory.h"
30 #include "itkProgressReporter.h"
31 
32 namespace otb
33 {
34 
38 template <class TInputImage, class TOutputImage>
41 {
42  m_Lower = std::numeric_limits < OutputPixelValueType >::lowest();
43  m_Upper = std::numeric_limits < OutputPixelValueType >::max();
44 }
46 
47 template <class TInputImage, class TOutputImage>
48 void
51 {
52  if ( m_Lower != val )
53  {
54  m_Lower = val;
55  this->GetFunctor().SetLowest( m_Lower );
56  this->Modified();
57  }
58 }
59 
60 template <class TInputImage, class TOutputImage>
61 void
64 {
65  if ( m_Upper != val )
66  {
67  m_Upper = val;
68  this->GetFunctor().SetHighest( m_Upper );
69  this->Modified();
70  }
71 }
72 
76 template <class TInputImage, class TOutputImage>
77 void
79 ::PrintSelf(std::ostream& os, itk::Indent indent) const
80 {
81  Superclass::PrintSelf(os, indent);
82 
83  os << indent << "Lower: "
84  << static_cast<typename itk::NumericTraits<OutputImagePixelType>::PrintType>(m_Lower)
85  << std::endl;
86  os << indent << "Upper: "
87  << static_cast<typename itk::NumericTraits<OutputImagePixelType>::PrintType>(m_Upper)
88  << std::endl;
89 }
90 
94 template <class TInputImage, class TOutputImage>
95 void
98 {
99  if (m_Upper != thresh
100  || m_Lower > std::numeric_limits < OutputPixelValueType >::lowest())
101  {
102  m_Lower = std::numeric_limits < OutputPixelValueType >::lowest();
103  m_Upper = thresh;
104  this->GetFunctor().SetLowest( m_Lower );
105  this->GetFunctor().SetHighest( m_Upper );
106  this->Modified();
107  }
108 }
110 
114 template <class TInputImage, class TOutputImage>
115 void
118 {
119  if (m_Lower != thresh || m_Upper < std::numeric_limits < OutputPixelValueType >::max())
120  {
121  m_Upper = std::numeric_limits < OutputPixelValueType >::max();
122  m_Lower = thresh;
123  this->GetFunctor().SetLowest( m_Lower );
124  this->GetFunctor().SetHighest( m_Upper );
125  this->Modified();
126  }
127 }
129 
130 
134 template <class TInputImage, class TOutputImage>
135 void
138 {
139  if (lower > upper)
140  {
141  itkExceptionMacro(<<"Lower threshold cannot be greater than upper threshold.");
142  return;
143  }
145 
146  if (m_Lower != lower || m_Upper != upper)
147  {
148  m_Lower = lower;
149  m_Upper = upper;
150  this->GetFunctor().SetLowest( m_Lower );
151  this->GetFunctor().SetHighest( m_Upper );
152  this->Modified();
153  }
154 }
155 
156 } // end namespace itk
157 
158 #endif
void SetLower(OutputPixelValueType val)
void ClampAbove(const OutputPixelValueType &thresh)
void ClampBelow(const OutputPixelValueType &thresh)
void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType
void SetUpper(OutputPixelValueType val)