18#ifndef itkShapeKeepNObjectsLabelMapFilter_h
19#define itkShapeKeepNObjectsLabelMapFilter_h
43template <
typename TImage>
86 itkSetMacro(ReverseOrdering,
bool);
87 itkGetConstReferenceMacro(ReverseOrdering,
bool);
88 itkBooleanMacro(ReverseOrdering);
109 this->
SetAttribute(LabelObjectType::GetAttributeFromName(s));
119 template <
typename TAttributeAccessor>
131 output2->SetBackgroundValue(output->GetBackgroundValue());
133 using LabelObjectPointer =
typename LabelObjectType::Pointer;
134 using VectorType = std::vector<LabelObjectPointer>;
139 VectorType labelObjects;
140 labelObjects.reserve(output->GetNumberOfLabelObjects());
141 typename ImageType::Iterator it(output);
142 while (!it.IsAtEnd())
144 labelObjects.push_back(it.GetLabelObject());
150 if (m_NumberOfObjects < output->GetNumberOfLabelObjects())
156 std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator);
161 std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator);
166 for (
auto it2 = end; it2 != labelObjects.end(); ++it2)
168 output2->AddLabelObject(*it2);
169 output->RemoveLabelObject(*it2);
185#ifndef ITK_MANUAL_INSTANTIATION
186# include "itkShapeKeepNObjectsLabelMapFilter.hxx"
OutputImageType * GetOutput()
InPlaceLabelMapFilter()=default
void AllocateOutputs() override
Control indentation during Print() invocation.
Implements progress tracking for a filter.
AttributeType m_Attribute
typename ImageType::PixelType PixelType
typename ImageType::Pointer ImagePointer
typename ImageType::ConstPointer ImageConstPointer
void SetAttribute(const std::string &s)
~ShapeKeepNObjectsLabelMapFilter() override=default
typename LabelObjectType::AttributeType AttributeType
void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
static constexpr unsigned int ImageDimension
void TemplatedGenerateData(const TAttributeAccessor &)
ShapeKeepNObjectsLabelMapFilter()
void GenerateData() override
typename ImageType::LabelObjectType LabelObjectType
typename ImageType::IndexType IndexType
virtual void SetAttribute(AttributeType _arg)
SizeValueType m_NumberOfObjects
ShapeKeepNObjectsLabelMapFilter Self
InPlaceLabelMapFilter< LabelMapType > Superclass
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType