18 #ifndef __itkShapeRelabelLabelMapFilter_h
19 #define __itkShapeRelabelLabelMapFilter_h
43 template<
class TImage >
65 itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
73 #ifdef ITK_USE_CONCEPT_CHECKING
90 itkSetMacro(ReverseOrdering,
bool);
91 itkGetConstReferenceMacro(ReverseOrdering,
bool);
92 itkBooleanMacro(ReverseOrdering);
101 void SetAttribute(
const std::string & s)
103 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
113 template<
class TAttributeAccessor >
114 void TemplatedGenerateData(
const TAttributeAccessor &)
117 this->AllocateOutputs();
121 typedef typename LabelObjectType::Pointer LabelObjectPointer;
122 typedef std::vector< LabelObjectPointer > VectorType;
124 ProgressReporter progress(
this, 0, 2 * output->GetNumberOfLabelObjects() );
127 VectorType labelObjects;
128 labelObjects.reserve( output->GetNumberOfLabelObjects() );
129 for (
typename ImageType::Iterator it( output );
133 labelObjects.push_back(it.GetLabelObject());
138 if ( m_ReverseOrdering )
140 std::sort( labelObjects.begin(), labelObjects.end(),
145 std::sort( labelObjects.begin(), labelObjects.end(),
151 output->ClearLabels();
153 typename VectorType::const_iterator it2 = labelObjects.begin();
154 while ( it2 != labelObjects.end() )
157 if ( label == output->GetBackgroundValue() )
161 ( *it2 )->SetLabel(label);
162 output->AddLabelObject(*it2);
166 progress.CompletedPixel();
172 void PrintSelf(std::ostream & os,
Indent indent)
const;
180 void operator=(
const Self &);
184 #ifndef ITK_MANUAL_INSTANTIATION
185 #include "itkShapeRelabelLabelMapFilter.hxx"