17 #ifndef __itkMergeLabelMapFilter_txx
18 #define __itkMergeLabelMapFilter_txx
27 template <
class TImage>
31 this->m_Method = KEEP;
34 template <
class TImage>
40 this->AllocateOutputs();
42 switch( this->m_Method )
46 this->MergeWithKeep();
51 this->MergeWithAggregate();
56 this->MergeWithPack();
61 this->MergeWithStrict();
66 itkExceptionMacro(<<
"No such method: " << this->m_Method );
71 template <
class TImage>
79 typedef std::deque< LabelObjectPointer >
VectorType;
80 VectorType labelObjects;
84 for(
unsigned int i=1; i < this->GetNumberOfInputs(); i++ )
88 typename LabelObjectContainerType::const_iterator it2 = otherLabelObjects.begin();
90 while( it2 != otherLabelObjects.end() )
94 newLo->CopyAllFrom( lo );
96 if( ! output->HasLabel( newLo->GetLabel() ) )
99 output->AddLabelObject( newLo );
104 labelObjects.push_back( newLo );
113 typename VectorType::iterator it = labelObjects.begin();
114 while( it != labelObjects.end() )
116 output->PushLabelObject( *it );
123 template <
class TImage>
133 for(
unsigned int i=1; i<this->GetNumberOfInputs(); i++ )
136 typename LabelObjectContainerType::const_iterator it2 = otherLabelObjects.begin();
138 while( it2 != otherLabelObjects.end() )
142 newLo->CopyAllFrom( lo );
144 if( ! output->HasLabel( newLo->GetLabel() ) )
147 output->AddLabelObject( newLo );
151 itkExceptionMacro(<<
"Label "
152 <<
static_cast< typename itk::NumericTraits< PixelType >::PrintType
>( newLo->GetLabel() )
153 <<
" from input " << i
154 <<
" is already in use.");
165 template <
class TImage>
175 for(
unsigned int i=1; i<this->GetNumberOfInputs(); i++ )
179 typename LabelObjectContainerType::const_iterator it2 = otherLabelObjects.begin();
181 while( it2 != otherLabelObjects.end() )
185 if( ! output->HasLabel( lo->GetLabel() ) )
189 newLo->CopyAllFrom( lo );
190 output->AddLabelObject( newLo );
194 if( lo->GetLabel() != output->GetBackgroundValue() )
201 while( lit != lineContainer.end() )
203 mainLo->AddLine( *lit );
220 template <
class TImage>
234 output->ClearLabels();
236 typename LabelObjectContainerType::iterator it = labelObjects.begin();
238 while( it != labelObjects.end() )
240 output->PushLabelObject( it->second );
248 for(
unsigned int i=1; i<this->GetNumberOfInputs(); i++ )
251 typename LabelObjectContainerType::const_iterator it2 = otherLabelObjects.begin();
253 while( it2 != otherLabelObjects.end() )
257 newLo->CopyAllFrom( lo );
258 output->PushLabelObject( newLo );
268 template <
class TImage>
273 Superclass::PrintSelf(os,indent);
275 os << indent <<
"Method: " << this->m_Method << std::endl;