22 #ifndef otbClampVectorImageFilter_hxx
23 #define otbClampVectorImageFilter_hxx
26 #include "itkImageRegionIterator.h"
27 #include "itkNumericTraits.h"
28 #include "itkObjectFactory.h"
29 #include "itkProgressReporter.h"
37 template <
class TInputImage,
class TOutputImage>
42 m_DLower(static_cast<double>(m_Lower)),
43 m_DUpper(static_cast<double>(m_Upper))
45 this->DynamicMultiThreadingOn();
52 template <
class TInputImage,
class TOutputImage>
55 Superclass::PrintSelf(os, indent);
57 os << indent <<
"Lower: " <<
static_cast<typename itk::NumericTraits<OutputImageInternalPixelType>::PrintType
>(m_Lower) << std::endl;
58 os << indent <<
"Upper: " <<
static_cast<typename itk::NumericTraits<OutputImageInternalPixelType>::PrintType
>(m_Upper) << std::endl;
64 template <
class TInputImage,
class TOutputImage>
67 if (m_Upper != thresh || m_Lower > itk::NumericTraits<OutputImageInternalPixelType>::NonpositiveMin())
69 m_Lower = itk::NumericTraits<OutputImageInternalPixelType>::NonpositiveMin();
71 m_DUpper =
static_cast<double>(m_Upper);
80 template <
class TInputImage,
class TOutputImage>
83 if (m_Lower != thresh || m_Upper < itk::NumericTraits<OutputImageInternalPixelType>::max())
87 m_Upper = itk::NumericTraits<OutputImageInternalPixelType>::max();
97 template <
class TInputImage,
class TOutputImage>
102 itkExceptionMacro(<<
"Lower threshold cannot be greater than upper threshold.");
107 if (m_Lower != lower || m_Upper != upper)
121 template <
class TInputImage,
class TOutputImage>
124 itkDebugMacro(<<
"Actually executing");
132 typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
133 typedef itk::ImageRegionIterator<TOutputImage> OutputIterator;
135 InputIterator inIt(inputPtr, outputRegionForThread);
136 OutputIterator outIt(outputPtr, outputRegionForThread);
139 while (!outIt.IsAtEnd() && !inIt.IsAtEnd())
142 unsigned int l_size = inPix.Size();
144 outPix.SetSize(l_size);
145 for (
unsigned int i = 0; i < l_size; i++)
150 const double value =
static_cast<double>(inPix[i]);
152 if (m_DLower <= value && value <= m_DUpper)
158 else if (value < m_DLower)
162 else if (value > m_DUpper)
OutputImageType::RegionType OutputImageRegionType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
OutputImageType::InternalPixelType OutputImageInternalPixelType
OutputImageType::Pointer OutputImagePointer
OutputImageType::PixelType OutputImagePixelType
void ClampAbove(const OutputImageInternalPixelType &thresh)
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
void ClampBelow(const OutputImageInternalPixelType &thresh)
InputImageType::ConstPointer InputImagePointer
void ClampOutside(const OutputImageInternalPixelType &lower, const OutputImageInternalPixelType &upper)
InputImageType::PixelType InputImagePixelType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.