17 #ifndef __itkVotingBinaryImageFilter_txx
18 #define __itkVotingBinaryImageFilter_txx
35 template <
class TInputImage,
class TOutputImage>
40 m_ForegroundValue = NumericTraits<InputPixelType>::max();
41 m_BackgroundValue = NumericTraits<InputPixelType>::Zero;
43 m_SurvivalThreshold = 1;
46 template <
class TInputImage,
class TOutputImage>
52 Superclass::GenerateInputRequestedRegion();
56 const_cast< TInputImage *
>( this->GetInput() );
59 if ( !inputPtr || !outputPtr )
66 typename TInputImage::RegionType inputRequestedRegion;
67 inputRequestedRegion = inputPtr->GetRequestedRegion();
70 inputRequestedRegion.PadByRadius( m_Radius );
73 if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
75 inputPtr->SetRequestedRegion( inputRequestedRegion );
84 inputPtr->SetRequestedRegion( inputRequestedRegion );
87 InvalidRequestedRegionError e(__FILE__, __LINE__);
89 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
96 template<
class TInputImage,
class TOutputImage>
109 typename OutputImageType::Pointer output = this->GetOutput();
110 typename InputImageType::ConstPointer input = this->GetInput();
115 faceList = bC(input, outputRegionForThread, m_Radius);
119 ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
123 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
130 unsigned int neighborhoodSize = bit.
Size();
137 unsigned int count = 0;
138 for (
unsigned int i = 0; i < neighborhoodSize; ++i)
141 if( value == m_ForegroundValue )
147 if( inpixel == m_BackgroundValue )
149 if( count >= m_BirthThreshold )
151 it.Set( static_cast<OutputPixelType>( m_ForegroundValue ) );
155 it.Set( static_cast<OutputPixelType>( m_BackgroundValue ) );
160 if( inpixel == m_ForegroundValue )
162 if( count >= m_SurvivalThreshold )
164 it.Set( static_cast<OutputPixelType>( m_ForegroundValue ) );
168 it.Set( static_cast<OutputPixelType>( m_BackgroundValue ) );
174 progress.CompletedPixel();
182 template <
class TInputImage,
class TOutput>
189 Superclass::PrintSelf( os, indent );
190 os << indent <<
"Radius: " << m_Radius << std::endl;
191 os << indent <<
"Foreground value : "
192 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>( m_ForegroundValue )<< std::endl;
193 os << indent <<
"Background value : "
194 <<
static_cast<typename NumericTraits<InputPixelType>::PrintType
>( m_BackgroundValue ) << std::endl;
195 os << indent <<
"Birth Threshold : " << m_BirthThreshold << std::endl;
196 os << indent <<
"Survival Threshold : " << m_SurvivalThreshold << std::endl;