17 #ifndef itkLabelSampler_cpp
18 #define itkLabelSampler_cpp
21 #include "itkObjectFactory.h"
22 #include "itkImageRegionIterator.h"
23 #include "itkImageRegionConstIterator.h"
24 #include "itkImageIterator.h"
25 #include "itkImageConstIterator.h"
33 template<
class TImage>
40 this->AllocateOutputs();
43 TImage * output = this->GetOutput();
45 m_NumberOfSampledVoxels = 0;
47 ImageRegionConstIterator<TImage> inputIter(input, input->GetLargestPossibleRegion());
48 ImageRegionIterator<TImage> outputIter(output, output->GetLargestPossibleRegion());
49 while (!inputIter.IsAtEnd())
51 if (inputIter.Get() > 0)
54 if(m_LabelVoxelCountMap.find(inputIter.Get()) == m_LabelVoxelCountMap.end())
55 m_LabelVoxelCountMap[inputIter.Get()] = 0;
56 m_LabelVoxelCountMap[inputIter.Get()]++;
59 if(inputIter.Get() == m_Label || m_Label == -1 ){
60 r = (double)(rand()) / RAND_MAX;
63 outputIter.Set(inputIter.Get());
64 m_NumberOfSampledVoxels++;
82 #endif // itkLabelSampler_cpp
itk::SmartPointer< const Self > ConstPointer
virtual void GenerateData()