22 #ifndef otbClampImageFilter_hxx
23 #define otbClampImageFilter_hxx
26 #include "itkImageScanlineIterator.h"
27 #include "itkImageScanlineConstIterator.h"
28 #include "itkImageRegionIterator.h"
29 #include "itkNumericTraits.h"
30 #include "itkObjectFactory.h"
31 #include "itkProgressReporter.h"
40 template <
class TInputImage,
class TOutputImage>
46 this->DynamicMultiThreadingOn();
49 template <
class TInputImage,
class TOutputImage>
52 assert( lowerVal <= upperVal );
53 if ((m_Lower != lowerVal) || (m_Upper != upperVal))
57 this->GetFunctor().SetThresholds(m_Lower, m_Upper);
65 template <
class TInputImage,
class TOutputImage>
68 Superclass::PrintSelf(os, indent);
70 os << indent <<
"Lower: " <<
static_cast<typename itk::NumericTraits<OutputImagePixelType>::PrintType
>(m_Lower) << std::endl;
71 os << indent <<
"Upper: " <<
static_cast<typename itk::NumericTraits<OutputImagePixelType>::PrintType
>(m_Upper) << std::endl;
77 template <
class TInputImage,
class TOutputImage>
80 if (m_Upper != thresh || m_Lower > std::numeric_limits<OutputPixelValueType>::lowest())
82 m_Lower = std::numeric_limits<OutputPixelValueType>::lowest();
84 this->GetFunctor().SetThresholds(m_Lower, m_Upper);
93 template <
class TInputImage,
class TOutputImage>
96 if (m_Lower != thresh || m_Upper < std::numeric_limits<OutputPixelValueType>::max())
98 m_Upper = std::numeric_limits<OutputPixelValueType>::max();
100 this->GetFunctor().SetThresholds(m_Lower, m_Upper);
110 template <
class TInputImage,
class TOutputImage>
115 itkExceptionMacro(<<
"Lower threshold cannot be greater than upper threshold.");
120 if (m_Lower != lower || m_Upper != upper)
124 this->GetFunctor().SetThresholds(m_Lower, m_Upper);
129 template <
class TInputImage,
class TOutputImage>
134 const auto& regionSize = outputRegionForThread.GetSize();
136 if (regionSize[0] == 0)
142 itk::ImageScanlineConstIterator<InputImageType> inIt(this->GetInput(), outputRegionForThread);
143 itk::ImageScanlineIterator<OutputImageType> outIt(this->GetOutput(), outputRegionForThread);
146 typename OutputImageType::PixelType outputValueHolder;
149 itk::NumericTraits<typename OutputImageType::PixelType>::SetLength(outputValueHolder, this->GetOutput()->GetNumberOfComponentsPerPixel());
151 while (!outIt.IsAtEnd())
154 for (; !outIt.IsAtEndOfLine(); ++outIt, ++inIt)
158 m_Functor(outputValueHolder, inIt.Get());
159 outIt.Set(outputValueHolder);
void SetThresholds(OutputPixelValueType lowerVal, OutputPixelValueType upperVal)
void ClampOutside(const OutputPixelValueType &lower, const OutputPixelValueType &upper)
typename OutputImageType::RegionType OutputImageRegionType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
typename itk::NumericTraits< OutputInternalPixelType >::ValueType OutputPixelValueType
void ClampAbove(const OutputPixelValueType &thresh)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void ClampBelow(const OutputPixelValueType &thresh)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.