18 #ifndef __itkShapeKeepNObjectsLabelMapFilter_h
19 #define __itkShapeKeepNObjectsLabelMapFilter_h
43 template<
typename TImage >
73 #ifdef ITK_USE_CONCEPT_CHECKING
89 itkSetMacro(ReverseOrdering,
bool);
90 itkGetConstReferenceMacro(ReverseOrdering,
bool);
91 itkBooleanMacro(ReverseOrdering);
111 this->
SetAttribute( LabelObjectType::GetAttributeFromName(s) );
120 template<
typename TAttributeAccessor >
131 output2->SetBackgroundValue( output->GetBackgroundValue() );
133 typedef typename LabelObjectType::Pointer LabelObjectPointer;
134 typedef std::vector< LabelObjectPointer > VectorType;
136 ProgressReporter progress(
this, 0, 2 * output->GetNumberOfLabelObjects() );
139 VectorType labelObjects;
140 labelObjects.reserve( output->GetNumberOfLabelObjects() );
141 typename ImageType::Iterator it( output );
142 while ( ! it.IsAtEnd() )
144 labelObjects.push_back( it.GetLabelObject() );
145 progress.CompletedPixel();
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);
163 progress.CompletedPixel();
166 for (
typename VectorType::const_iterator it2 = end;
167 it2 != labelObjects.end();
170 output2->AddLabelObject(*it2);
171 output->RemoveLabelObject(*it2);
172 progress.CompletedPixel();
190 #ifndef ITK_MANUAL_INSTANTIATION
191 #include "itkShapeKeepNObjectsLabelMapFilter.hxx"
ImageType::ConstPointer ImageConstPointer
void operator=(const Self &)
Light weight base class for most itk classes.
static const unsigned int ImageDimension
virtual void SetAttribute(AttributeType _arg)
void PrintSelf(std::ostream &os, Indent indent) const
InPlaceLabelMapFilter< TImage > Superclass
SizeValueType m_NumberOfObjects
unsigned long SizeValueType
void TemplatedGenerateData(const TAttributeAccessor &)
ShapeKeepNObjectsLabelMapFilter()
OutputImageType * GetOutput(void)
Base class for filters that takes an image as input and overwrites that image as the output...
ImageType::Pointer ImagePointer
Implements progress tracking for a filter.
virtual void AllocateOutputs()
Keep N objects according to their shape attributes.
LabelObjectType::AttributeType AttributeType
AttributeType m_Attribute
SmartPointer< Self > Pointer
void SetAttribute(const std::string &s)
ImageType::IndexType IndexType
SmartPointer< const Self > ConstPointer
~ShapeKeepNObjectsLabelMapFilter()
Control indentation during Print() invocation.
ImageType::LabelObjectType LabelObjectType
ShapeKeepNObjectsLabelMapFilter Self
ImageType::PixelType PixelType