17 #ifndef __itkLabelMapToBinaryImageFilter_txx
18 #define __itkLabelMapToBinaryImageFilter_txx
21 #include "itkNumericTraits.h"
28 template <
class TInputImage,
class TOutputImage>
32 this->m_BackgroundValue = NumericTraits<OutputImagePixelType>::NonpositiveMin();
33 this->m_ForegroundValue = NumericTraits<OutputImagePixelType>::max();
36 template <
class TInputImage,
class TOutputImage>
42 Superclass::GenerateInputRequestedRegion();
49 input->SetRequestedRegion( input->GetLargestPossibleRegion() );
54 template <
class TInputImage,
class TOutputImage>
59 this->GetOutput()->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
63 template<
class TInputImage,
class TOutputImage>
68 unsigned long numberOfThreads = this->GetNumberOfThreads();
71 numberOfThreads = vnl_math_min(
77 typename TOutputImage::RegionType splitRegion;
79 numberOfThreads = this->SplitRequestedRegion(0, numberOfThreads, splitRegion);
83 m_Barrier->Initialize( numberOfThreads );
85 this->Superclass::BeforeThreadedGenerateData();
89 template<
class TInputImage,
class TOutputImage>
98 if( this->GetNumberOfInputs() == 2 )
110 if( bg != this->m_ForegroundValue )
116 oIt.
Set( this->m_BackgroundValue );
130 oIt.
Set( this->m_BackgroundValue );
136 this->m_Barrier->Wait();
139 this->Superclass::ThreadedGenerateData( outputRegionForThread, threadId );
144 template<
class TInputImage,
class TOutputImage>
151 typedef typename LabelObjectType::LineContainerType LineContainerType;
153 typename LineContainerType::const_iterator lit;
154 LineContainerType & lineContainer = labelObject->GetLineContainer();
156 for( lit = lineContainer.begin(); lit != lineContainer.end(); lit++ )
160 unsigned long length = lit->GetLength();
162 for(
unsigned int i=0; i<length; i++)
164 output->SetPixel( idx, this->m_ForegroundValue );
171 template<
class TInputImage,
class TOutputImage >
176 this->Superclass::PrintSelf(os,indent);
178 os << indent <<
"ForegroundValue: "
179 <<
static_cast<typename NumericTraits<OutputImagePixelType>::PrintType
>(this->m_ForegroundValue) << std::endl;
180 os << indent <<
"BackgroundValue: "
181 <<
static_cast<typename NumericTraits<OutputImagePixelType>::PrintType
>(this->m_BackgroundValue) << std::endl;
182 os << indent <<
"Barrier object: " << this->m_Barrier.GetPointer() << std::endl;