18 #ifndef __itkShapeRelabelLabelMapFilter_h
19 #define __itkShapeRelabelLabelMapFilter_h
44 template<
class TImage >
66 itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
74 #ifdef ITK_USE_CONCEPT_CHECKING
91 itkSetMacro(ReverseOrdering,
bool);
92 itkGetConstReferenceMacro(ReverseOrdering,
bool);
93 itkBooleanMacro(ReverseOrdering);
102 void SetAttribute(
const std::string & s)
104 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
114 template<
class TAttributeAccessor >
115 void TemplatedGenerateData(
const TAttributeAccessor &)
118 this->AllocateOutputs();
122 typedef typename LabelObjectType::Pointer LabelObjectPointer;
123 typedef std::vector< LabelObjectPointer > VectorType;
125 ProgressReporter progress(
this, 0, 2 * output->GetNumberOfLabelObjects() );
128 VectorType labelObjects;
129 labelObjects.reserve( output->GetNumberOfLabelObjects() );
130 for (
typename ImageType::Iterator it( output );
134 labelObjects.push_back(it.GetLabelObject());
139 if ( m_ReverseOrdering )
141 std::sort( labelObjects.begin(), labelObjects.end(),
146 std::sort( labelObjects.begin(), labelObjects.end(),
152 output->ClearLabels();
154 typename VectorType::const_iterator it2 = labelObjects.begin();
155 while ( it2 != labelObjects.end() )
158 if ( label == output->GetBackgroundValue() )
162 ( *it2 )->SetLabel(label);
163 output->AddLabelObject(*it2);
167 progress.CompletedPixel();
173 void PrintSelf(std::ostream & os,
Indent indent)
const;
181 void operator=(
const Self &);
185 #ifndef ITK_MANUAL_INSTANTIATION
186 #include "itkShapeRelabelLabelMapFilter.hxx"