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))
50 template <
class TInputImage,
class TOutputImage>
53 Superclass::PrintSelf(os, indent);
55 os << indent <<
"Lower: " <<
static_cast<typename itk::NumericTraits<OutputImageInternalPixelType>::PrintType
>(m_Lower) << std::endl;
56 os << indent <<
"Upper: " <<
static_cast<typename itk::NumericTraits<OutputImageInternalPixelType>::PrintType
>(m_Upper) << std::endl;
62 template <
class TInputImage,
class TOutputImage>
65 if (m_Upper != thresh || m_Lower > itk::NumericTraits<OutputImageInternalPixelType>::NonpositiveMin())
67 m_Lower = itk::NumericTraits<OutputImageInternalPixelType>::NonpositiveMin();
69 m_DUpper =
static_cast<double>(m_Upper);
78 template <
class TInputImage,
class TOutputImage>
81 if (m_Lower != thresh || m_Upper < itk::NumericTraits<OutputImageInternalPixelType>::max())
85 m_Upper = itk::NumericTraits<OutputImageInternalPixelType>::max();
95 template <
class TInputImage,
class TOutputImage>
100 itkExceptionMacro(<<
"Lower threshold cannot be greater than upper threshold.");
105 if (m_Lower != lower || m_Upper != upper)
119 template <
class TInputImage,
class TOutputImage>
122 itkDebugMacro(<<
"Actually executing");
130 typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
131 typedef itk::ImageRegionIterator<TOutputImage> OutputIterator;
133 InputIterator inIt(inputPtr, outputRegionForThread);
134 OutputIterator outIt(outputPtr, outputRegionForThread);
137 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
140 while (!outIt.IsAtEnd() && !inIt.IsAtEnd())
143 unsigned int l_size = inPix.Size();
145 outPix.SetSize(l_size);
146 for (
unsigned int i = 0; i < l_size; i++)
151 const double value =
static_cast<double>(inPix[i]);
153 if (m_DLower <= value && value <= m_DUpper)
159 else if (value < m_DLower)
163 else if (value > m_DUpper)
172 progress.CompletedPixel();