4 #include <itkImageRegionConstIterator.h> 5 #include <itkImageRegionIterator.h> 11 template <
class TPixelType>
13 MajorityLabelVotingImageFilter <TPixelType>
16 unsigned int numInputs = this->GetNumberOfIndexedInputs();
18 typedef itk::ImageRegionConstIterator <InputImageType> InputIteratorType;
19 typedef itk::ImageRegionIterator <OutputImageType> OutputIteratorType;
21 std::vector<InputIteratorType> inputIterators (numInputs);
23 for (
unsigned int i = 0; i < numInputs; ++i)
24 inputIterators[i] = InputIteratorType (this->GetInput(i), region);
26 OutputIteratorType outputIterator (this->GetOutput(), region);
28 std::map <TPixelType,unsigned int> vecCount;
29 using MapIterator =
typename std::map <TPixelType,unsigned int>::iterator;
30 while (!inputIterators[0].IsAtEnd())
34 for (
unsigned int i = 0;i < numInputs;++i)
36 TPixelType value = inputIterators[i].Get();
37 if (vecCount.count(value) == 0)
43 TPixelType outValue = 0;
44 unsigned int maxCount = 0;
45 for (MapIterator it = vecCount.begin();it != vecCount.end();++it)
47 if (it->second > maxCount)
50 maxCount = it->second;
55 outputIterator.Set(outValue);
56 for (
unsigned int i = 0;i < numInputs;++i)
typename InputImageType::RegionType InputRegionType