18 #ifndef itkShapeRelabelLabelMapFilter_h
19 #define itkShapeRelabelLabelMapFilter_h
45 template <
typename TImage>
68 static constexpr
unsigned int ImageDimension = TImage::ImageDimension;
76 #ifdef ITK_USE_CONCEPT_CHECKING
92 itkSetMacro(ReverseOrdering,
bool);
93 itkGetConstReferenceMacro(ReverseOrdering,
bool);
94 itkBooleanMacro(ReverseOrdering);
106 this->SetAttribute(LabelObjectType::GetAttributeFromName(s));
115 GenerateData()
override;
117 template <
typename TAttributeAccessor>
122 this->AllocateOutputs();
127 using VectorType = std::vector<LabelObjectPointer>;
133 labelObjects.reserve(output->GetNumberOfLabelObjects());
134 for (
typename ImageType::Iterator it(output); !it.IsAtEnd(); ++it)
136 labelObjects.push_back(it.GetLabelObject());
137 progress.CompletedPixel();
141 if (m_ReverseOrdering)
143 std::sort(labelObjects.begin(),
149 std::sort(labelObjects.begin(),
156 output->ClearLabels();
158 typename VectorType::const_iterator it2 = labelObjects.
begin();
159 while (it2 != labelObjects.end())
162 if (label == output->GetBackgroundValue())
166 (*it2)->SetLabel(label);
167 output->AddLabelObject(*it2);
171 progress.CompletedPixel();
178 PrintSelf(std::ostream & os,
Indent indent)
const override;
180 bool m_ReverseOrdering{};
186 #ifndef ITK_MANUAL_INSTANTIATION
187 # include "itkShapeRelabelLabelMapFilter.hxx"