18 #ifndef itkShapeRelabelLabelMapFilter_h
19 #define itkShapeRelabelLabelMapFilter_h
44 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);
105 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
113 void GenerateData()
override;
115 template<
typename TAttributeAccessor >
119 this->AllocateOutputs();
123 using LabelObjectPointer =
typename LabelObjectType::Pointer;
124 using VectorType = std::vector< LabelObjectPointer >;
126 ProgressReporter progress(
this, 0, 2 * output->GetNumberOfLabelObjects() );
130 labelObjects.reserve( output->GetNumberOfLabelObjects() );
131 for (
typename ImageType::Iterator it( output );
135 labelObjects.push_back(it.GetLabelObject());
136 progress.CompletedPixel();
140 if ( m_ReverseOrdering )
142 std::sort( labelObjects.begin(), labelObjects.end(),
147 std::sort( labelObjects.begin(), labelObjects.end(),
153 output->ClearLabels();
155 typename VectorType::const_iterator it2 = labelObjects.begin();
156 while ( it2 != labelObjects.end() )
159 if ( label == output->GetBackgroundValue() )
163 ( *it2 )->SetLabel(label);
164 output->AddLabelObject(*it2);
168 progress.CompletedPixel();
174 void PrintSelf(std::ostream & os,
Indent indent)
const override;
182 #ifndef ITK_MANUAL_INSTANTIATION
183 #include "itkShapeRelabelLabelMapFilter.hxx"
Relabels objects according to their shape attributes.
Light weight base class for most itk classes.
typename ImageType::ConstPointer ImageConstPointer
Define numeric traits for std::vector.
typename LabelObjectType::AttributeType AttributeType
typename ImageType::Pointer ImagePointer
void SetAttribute(const std::string &s)
ImageBaseType::IndexType IndexType
Base class for filters that takes an image as input and overwrites that image as the output...
Implements progress tracking for a filter.
Control indentation during Print() invocation.
typename ImageType::IndexType IndexType
ImageBaseType::SpacingType VectorType
AttributeType m_Attribute
void TemplatedGenerateData(const TAttributeAccessor &)
typename ImageType::PixelType PixelType
typename ImageType::LabelObjectType LabelObjectType