18 #ifndef itkShapeRelabelLabelMapFilter_h
19 #define itkShapeRelabelLabelMapFilter_h
44 template<
typename TImage >
66 itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
74 #ifdef ITK_USE_CONCEPT_CHECKING
90 itkSetMacro(ReverseOrdering,
bool);
91 itkGetConstReferenceMacro(ReverseOrdering,
bool);
92 itkBooleanMacro(ReverseOrdering);
103 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
111 void GenerateData() ITK_OVERRIDE;
113 template< typename 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 ITK_OVERRIDE;
183 #ifndef ITK_MANUAL_INSTANTIATION
184 #include "itkShapeRelabelLabelMapFilter.hxx"
Relabels objects according to their shape attributes.
Light weight base class for most itk classes.
~ShapeRelabelLabelMapFilter() override
ShapeRelabelLabelMapFilter Self
ImageType::IndexType IndexType
ImageType::ConstPointer ImageConstPointer
ImageBaseType::SpacingType VectorType
void SetAttribute(const std::string &s)
ImageType::LabelObjectType LabelObjectType
SmartPointer< Self > Pointer
Base class for filters that takes an image as input and overwrites that image as the output...
LabelObjectType::AttributeType AttributeType
Implements progress tracking for a filter.
InPlaceLabelMapFilter< TImage > Superclass
Control indentation during Print() invocation.
ImageType::PixelType PixelType
AttributeType m_Attribute
ImageType::Pointer ImagePointer
ImageBaseType::IndexType IndexType
SmartPointer< const Self > ConstPointer