22 #ifndef otbThresholdVectorImageFilter_hxx
23 #define otbThresholdVectorImageFilter_hxx
26 #include "itkImageRegionIterator.h"
27 #include "itkNumericTraits.h"
28 #include "itkObjectFactory.h"
29 #include "itkProgressReporter.h"
37 template <
class TInputImage,
class TOutputImage>
49 template <
class TInputImage,
class TOutputImage>
52 Superclass::PrintSelf(os, indent);
54 os << indent <<
"OutsideValue: " <<
static_cast<typename itk::NumericTraits<InputImageInternalPixelType>::PrintType
>(m_OutsideValue) << std::endl;
55 os << indent <<
"Lower: " <<
static_cast<typename itk::NumericTraits<InputImageInternalPixelType>::PrintType
>(m_Lower) << std::endl;
56 os << indent <<
"Upper: " <<
static_cast<typename itk::NumericTraits<InputImageInternalPixelType>::PrintType
>(m_Upper) << std::endl;
62 template <
class TInputImage,
class TOutputImage>
65 if (m_Upper != thresh || m_Lower > itk::NumericTraits<InputImageInternalPixelType>::NonpositiveMin())
67 m_Lower = itk::NumericTraits<InputImageInternalPixelType>::NonpositiveMin();
77 template <
class TInputImage,
class TOutputImage>
80 if (m_Lower != thresh || m_Upper < itk::NumericTraits<InputImageInternalPixelType>::max())
83 m_Upper = itk::NumericTraits<InputImageInternalPixelType>::max();
93 template <
class TInputImage,
class TOutputImage>
98 itkExceptionMacro(<<
"Lower threshold cannot be greater than upper threshold.");
103 if (m_Lower != lower || m_Upper != upper)
115 template <
class TInputImage,
class TOutputImage>
118 itkDebugMacro(<<
"Actually executing");
126 typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
127 typedef itk::ImageRegionIterator<TOutputImage> OutputIterator;
129 InputIterator inIt(inputPtr, outputRegionForThread);
130 OutputIterator outIt(outputPtr, outputRegionForThread);
133 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
136 while (!outIt.IsAtEnd() && !inIt.IsAtEnd())
139 unsigned int l_size = inPix.Size();
141 outPix.SetSize(l_size);
142 for (
unsigned int i = 0; i < l_size; i++)
146 if (m_Lower <= value && value <= m_Upper)
162 progress.CompletedPixel();