18 #ifndef itkShapeUniqueLabelMapFilter_h
19 #define itkShapeUniqueLabelMapFilter_h
42 template<
typename TImage >
60 typedef typename LabelObjectType::LineType
LineType;
66 TImage::ImageDimension);
75 #ifdef ITK_USE_CONCEPT_CHECKING
91 itkGetConstMacro(ReverseOrdering,
bool);
92 itkSetMacro(ReverseOrdering,
bool);
93 itkBooleanMacro(ReverseOrdering);
104 this->
SetAttribute( LabelObjectType::GetAttributeFromName(s) );
114 template< typename TAttributeAccessor >
121 typedef typename std::priority_queue< LineOfLabelObject, std::vector< LineOfLabelObject >,
123 PriorityQueueType priorityQueue;
128 for (
typename ImageType::Iterator it( this->
GetLabelMap() );
135 labelObject->Optimize();
137 typename LabelObjectType::ConstLineIterator lit( labelObject );
138 while( ! lit.IsAtEnd() )
145 labelObject->Clear();
151 if ( priorityQueue.empty() )
157 typedef typename std::deque< LineOfLabelObject > LinesType;
160 lines.push_back( priorityQueue.top() );
165 while ( !priorityQueue.empty() )
171 bool newMainLine =
false;
175 if ( idx[i] != prevIdx[i] )
191 if ( prevIdx[0] + prevLength >= idx[0] )
200 typename TAttributeAccessor::AttributeValueType prevAttr = accessor(prev.
labelObject);
201 typename TAttributeAccessor::AttributeValueType attr = accessor(l.
labelObject);
217 if ( attr > prevAttr )
234 if ( prevIdx[0] + prevLength > idx[0] + length )
240 newIdx[0] = idx[0] + length;
245 prevLength = idx[0] - prevIdx[0];
246 if ( prevLength != 0 )
248 lines.back(). line.SetLength(idx[0] - prevIdx[0]);
263 if ( prevIdx[0] + prevLength > idx[0] + length )
270 newIdx[0] = prevIdx[0] + prevLength;
272 l.
line.SetIndex(newIdx);
273 l.
line.SetLength(newLength);
287 prevIdx = prev.
line.GetIndex();
291 for (
size_t i = 0; i < lines.size(); ++i )
298 typename ImageType::Iterator it( this->
GetLabelMap() );
299 while ( ! it.IsAtEnd() )
301 typename LabelObjectType::LabelType label = it.GetLabel();
304 if ( labelObject->Empty() )
318 virtual void PrintSelf(std::ostream & os,
Indent indent)
const ITK_OVERRIDE;
324 void operator=(const
Self &) ITK_DELETE_FUNCTION;
328 typedef typename LabelObjectType::LineType
LineType;
332 this->labelObject = _lo;
346 if ( lla.
line.GetIndex()[i] > llb.
line.GetIndex()[i] )
350 else if ( lla.
line.GetIndex()[i] < llb.
line.GetIndex()[i] )
361 #ifndef ITK_MANUAL_INSTANTIATION
362 #include "itkShapeUniqueLabelMapFilter.hxx"
bool operator()(const LineOfLabelObject &lla, const LineOfLabelObject &llb)
~ShapeUniqueLabelMapFilter()
Light weight base class for most itk classes.
signed long OffsetValueType
virtual void SetAttribute(AttributeType _arg)
LabelObjectType::LineType LineType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< Self > Pointer
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potetially different types...
virtual void AllocateOutputs() override
ImageType::LabelObjectType LabelObjectType
ImageType::IndexType IndexType
virtual InputImageType * GetLabelMap() override
ImageType::ConstPointer ImageConstPointer
Base class for filters that takes an image as input and overwrites that image as the output...
ImageType::Pointer ImagePointer
Remove some pixels in the label object according to the value of their shape attribute to ensure that...
SmartPointer< const Self > ConstPointer
LabelObjectType::LineType LineType
static const unsigned int ImageDimension
ShapeUniqueLabelMapFilter()
Implements progress tracking for a filter.
LabelObjectType * labelObject
LabelObjectType::AttributeType AttributeType
ImageType::PixelType PixelType
void TemplatedGenerateData(const TAttributeAccessor &accessor)
void SetAttribute(const std::string &s)
LineOfLabelObject(const LineType _line, LabelObjectType *_lo)
Control indentation during Print() invocation.
virtual void GenerateData() override
InPlaceLabelMapFilter< TImage > Superclass
AttributeType m_Attribute
ShapeUniqueLabelMapFilter Self