18 #ifndef itkShapeRelabelLabelMapFilter_h
19 #define itkShapeRelabelLabelMapFilter_h
44 template <
typename TImage>
67 static constexpr
unsigned int ImageDimension = TImage::ImageDimension;
75 #ifdef ITK_USE_CONCEPT_CHECKING
91 itkSetMacro(ReverseOrdering,
bool);
92 itkGetConstReferenceMacro(ReverseOrdering,
bool);
93 itkBooleanMacro(ReverseOrdering);
105 this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
114 GenerateData()
override;
116 template <
typename TAttributeAccessor>
121 this->AllocateOutputs();
125 using LabelObjectPointer =
typename LabelObjectType::Pointer;
126 using VectorType = std::vector<LabelObjectPointer>;
132 labelObjects.reserve(output->GetNumberOfLabelObjects());
133 for (
typename ImageType::Iterator it(output); !it.IsAtEnd(); ++it)
135 labelObjects.push_back(it.GetLabelObject());
136 progress.CompletedPixel();
140 if (m_ReverseOrdering)
142 std::sort(labelObjects.begin(),
148 std::sort(labelObjects.begin(),
155 output->ClearLabels();
157 typename VectorType::const_iterator it2 = labelObjects.begin();
158 while (it2 != labelObjects.end())
161 if (label == output->GetBackgroundValue())
165 (*it2)->SetLabel(label);
166 output->AddLabelObject(*it2);
170 progress.CompletedPixel();
177 PrintSelf(std::ostream & os,
Indent indent)
const override;
185 #ifndef ITK_MANUAL_INSTANTIATION
186 # include "itkShapeRelabelLabelMapFilter.hxx"