22 #ifndef otbThresholdImageToPointSetFilter_hxx
23 #define otbThresholdImageToPointSetFilter_hxx
26 #include "itkImageRegionConstIterator.h"
27 #include "itkProgressReporter.h"
33 template <
class TInputImage,
class TOutputPo
intSet>
36 m_LowerThreshold = itk::NumericTraits<InputPixelType>::NonpositiveMin();
37 m_UpperThreshold = itk::NumericTraits<InputPixelType>::max();
40 template <
class TInputImage,
class TOutputPo
intSet>
42 itk::ThreadIdType threadId)
44 this->m_PointsContainerPerThread[threadId] = PointsContainerType::New();
45 this->m_PointDataContainerPerThread[threadId] = PointDataContainerType::New();
49 itk::ImageRegionConstIterator<TInputImage> inputIt(inputPtr, inputRegionForThread);
51 itk::ProgressReporter progress(
this, threadId, inputRegionForThread.GetNumberOfPixels());
53 typename OutputPointSetType::PointType position;
56 unsigned long currentIndex = 0;
58 while (!inputIt.IsAtEnd())
61 if ((value >= m_LowerThreshold) && (value <= m_UpperThreshold))
64 const IndexType index = inputIt.GetIndex();
65 position[0] = index[0];
66 position[1] = index[1];
67 this->m_PointsContainerPerThread[threadId]->InsertElement(currentIndex, position);
68 this->m_PointDataContainerPerThread[threadId]->InsertElement(currentIndex,
static_cast<typename PointDataContainerType::Element
>(value));
72 progress.CompletedPixel();
79 template <
class TInputImage,
class TOutputPo
intSet>
82 Superclass::PrintSelf(os, indent);
83 os << indent <<
"LowerThreshold : " << m_LowerThreshold << std::endl;
84 os << indent <<
"UpperThreshold : " << m_UpperThreshold << std::endl;