ITK  6.0.0
Insight Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Attributes | List of all members
itk::LabelObject< TLabel, VImageDimension > Class Template Reference

#include <itkLabelObject.h>

Detailed Description

template<typename TLabel, unsigned int VImageDimension>
class itk::LabelObject< TLabel, VImageDimension >

The base class for the representation of a labeled binary object in an image.

LabelObject is the base class to represent a labeled object in an image. It should be used associated with the LabelMap.

LabelObject store mainly 2 things: the label of the object, and a set of lines which are part of the object. No attribute is available in that class, so this class can be used as a base class to implement a label object with attribute, or when no attribute is needed (see the reconstruction filters for an example. If a simple attribute is needed, AttributeLabelObject can be used directly.

All the subclasses of LabelObject have to reimplement the CopyAttributesFrom() and CopyAllFrom() method. No need to reimplement CopyLinesFrom() since all derived class share the same type line data members.

The pixels locations belonging to the LabelObject can be obtained using:

for(unsigned int pixelId = 0; pixelId < labelObject->Size(); pixelId++)
{
std::cout << labelObject->GetIndex(pixelId);
}
Author
Gaetan Lehmann. Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France.

This implementation was taken from the Insight Journal paper: https://doi.org/10.54294/q6auw4

See also
LabelMapFilter, AttributeLabelObject
Examples
SphinxExamples/src/Filtering/ImageFusion/OverlayLabelMapOnTopOfAnImage/Code.cxx, SphinxExamples/src/Filtering/LabelMap/ApplyMorphologicalClosingOnAllLabelObjects/Code.cxx, SphinxExamples/src/Filtering/LabelMap/ApplyMorphologicalClosingOnSpecificLabelObject/Code.cxx, SphinxExamples/src/Filtering/LabelMap/ExtractGivenLabelObject/Code.cxx, and SphinxExamples/src/Filtering/LabelMap/MaskOneImageGivenLabelMap/Code.cxx.

Definition at line 65 of file itkLabelObject.h.

+ Inheritance diagram for itk::LabelObject< TLabel, VImageDimension >:
+ Collaboration diagram for itk::LabelObject< TLabel, VImageDimension >:

Classes

class  ConstIndexIterator
 
class  ConstLineIterator
 

Public Types

using AttributeType = unsigned int
 
using ConstPointer = SmartPointer< const Self >
 
using ConstWeakPointer = WeakPointer< const Self >
 
using IndexType = Index< VImageDimension >
 
using LabelObjectType = Self
 
using LabelType = TLabel
 
using LengthType = typename LineType::LengthType
 
using LineType = LabelObjectLine< VImageDimension >
 
using OffsetType = Offset< VImageDimension >
 
using Pointer = SmartPointer< Self >
 
using Self = LabelObject
 
using SizeValueType = itk::SizeValueType
 
using Superclass = LightObject
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = LightObject
 

Public Member Functions

void AddIndex (const IndexType &idx)
 
void AddLine (const IndexType &idx, const LengthType &length)
 
void AddLine (const LineType &line)
 
void Clear ()
 
template<typename TSourceLabelObject >
void CopyAllFrom (const TSourceLabelObject *src)
 
template<typename TSourceLabelObject >
void CopyAttributesFrom (const TSourceLabelObject *src)
 
template<typename TSourceLabelObject >
void CopyLinesFrom (const TSourceLabelObject *src)
 
bool Empty () const
 
IndexType GetIndex (SizeValueType offset) const
 
const LabelTypeGetLabel () const
 
LineTypeGetLine (SizeValueType i)
 
const LineTypeGetLine (SizeValueType i) const
 
const char * GetNameOfClass () const override
 
SizeValueType GetNumberOfLines () const
 
bool HasIndex (const IndexType &idx) const
 
void Optimize ()
 
bool RemoveIndex (const IndexType &idx)
 
void SetLabel (const LabelType &label)
 
void Shift (OffsetType offset)
 
SizeValueType Size () const
 
- Public Member Functions inherited from itk::LightObject
Pointer Clone () const
 
virtual Pointer CreateAnother () const
 
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
void Print (std::ostream &os, Indent indent=0) const
 
virtual void Register () const
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const noexcept
 

Static Public Member Functions

static AttributeType GetAttributeFromName (const std::string &s)
 
static std::string GetNameFromAttribute (const AttributeType &a)
 
static Pointer New ()
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Static Public Attributes

static constexpr unsigned int ImageDimension = VImageDimension
 
static constexpr AttributeType LABEL = 0
 

Protected Member Functions

 LabelObject ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Types

using LineContainerType = typename std::deque< LineType >
 

Private Attributes

LabelType m_Label {}
 
LineContainerType m_LineContainer {}
 

Additional Inherited Members

- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount {}
 

Member Typedef Documentation

◆ AttributeType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::AttributeType = unsigned int

Definition at line 92 of file itkLabelObject.h.

◆ ConstPointer

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::ConstPointer = SmartPointer<const Self>

Definition at line 76 of file itkLabelObject.h.

◆ ConstWeakPointer

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::ConstWeakPointer = WeakPointer<const Self>

Definition at line 77 of file itkLabelObject.h.

◆ IndexType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::IndexType = Index<VImageDimension>

Definition at line 87 of file itkLabelObject.h.

◆ LabelObjectType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::LabelObjectType = Self

Definition at line 74 of file itkLabelObject.h.

◆ LabelType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::LabelType = TLabel

Definition at line 89 of file itkLabelObject.h.

◆ LengthType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::LengthType = typename LineType::LengthType

Definition at line 91 of file itkLabelObject.h.

◆ LineContainerType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::LineContainerType = typename std::deque<LineType>
private

Definition at line 408 of file itkLabelObject.h.

◆ LineType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::LineType = LabelObjectLine<VImageDimension>

Definition at line 90 of file itkLabelObject.h.

◆ OffsetType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::OffsetType = Offset<VImageDimension>

Definition at line 88 of file itkLabelObject.h.

◆ Pointer

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::Pointer = SmartPointer<Self>

Definition at line 75 of file itkLabelObject.h.

◆ Self

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::Self = LabelObject

Standard class type aliases

Definition at line 72 of file itkLabelObject.h.

◆ SizeValueType

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::SizeValueType = itk::SizeValueType

Definition at line 93 of file itkLabelObject.h.

◆ Superclass

template<typename TLabel, unsigned int VImageDimension>
using itk::LabelObject< TLabel, VImageDimension >::Superclass = LightObject

Definition at line 73 of file itkLabelObject.h.

Constructor & Destructor Documentation

◆ LabelObject()

template<typename TLabel, unsigned int VImageDimension>
itk::LabelObject< TLabel, VImageDimension >::LabelObject ( )
protected

Member Function Documentation

◆ AddIndex()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::AddIndex ( const IndexType idx)

Add an index to the object. If the index is already in the object, the index can be found several time in the object.

◆ AddLine() [1/2]

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::AddLine ( const IndexType idx,
const LengthType length 
)

Add a new line to the object, without any check.

◆ AddLine() [2/2]

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::AddLine ( const LineType line)

Add a new line to the object, without any check.

◆ Clear()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::Clear ( )

◆ CopyAllFrom()

template<typename TLabel, unsigned int VImageDimension>
template<typename TSourceLabelObject >
void itk::LabelObject< TLabel, VImageDimension >::CopyAllFrom ( const TSourceLabelObject< TLabel, VImageDimension > *  src)

Copy the lines, the label and the attributes from another node.

◆ CopyAttributesFrom()

template<typename TLabel, unsigned int VImageDimension>
template<typename TSourceLabelObject >
void itk::LabelObject< TLabel, VImageDimension >::CopyAttributesFrom ( const TSourceLabelObject< TLabel, VImageDimension > *  src)

Copy the label and the attributes of another node to this one

◆ CopyLinesFrom()

template<typename TLabel, unsigned int VImageDimension>
template<typename TSourceLabelObject >
void itk::LabelObject< TLabel, VImageDimension >::CopyLinesFrom ( const TSourceLabelObject< TLabel, VImageDimension > *  src)

Copy the lines of another node to this one

◆ Empty()

template<typename TLabel, unsigned int VImageDimension>
bool itk::LabelObject< TLabel, VImageDimension >::Empty ( ) const

Returns true if there no line in the container (and thus no pixel in the object.

◆ GetAttributeFromName()

template<typename TLabel, unsigned int VImageDimension>
static AttributeType itk::LabelObject< TLabel, VImageDimension >::GetAttributeFromName ( const std::string &  s)
static

◆ GetIndex()

template<typename TLabel, unsigned int VImageDimension>
IndexType itk::LabelObject< TLabel, VImageDimension >::GetIndex ( SizeValueType  offset) const

Get the index of the ith pixel associated with the object. Valid indices are from 0 to LabelObject->GetSize() - 1.

◆ GetLabel()

template<typename TLabel, unsigned int VImageDimension>
const LabelType& itk::LabelObject< TLabel, VImageDimension >::GetLabel ( ) const

Set/Get the label associated with the object.

◆ GetLine() [1/2]

template<typename TLabel, unsigned int VImageDimension>
LineType& itk::LabelObject< TLabel, VImageDimension >::GetLine ( SizeValueType  i)

◆ GetLine() [2/2]

template<typename TLabel, unsigned int VImageDimension>
const LineType& itk::LabelObject< TLabel, VImageDimension >::GetLine ( SizeValueType  i) const

◆ GetNameFromAttribute()

template<typename TLabel, unsigned int VImageDimension>
static std::string itk::LabelObject< TLabel, VImageDimension >::GetNameFromAttribute ( const AttributeType a)
static

◆ GetNameOfClass()

template<typename TLabel, unsigned int VImageDimension>
const char* itk::LabelObject< TLabel, VImageDimension >::GetNameOfClass ( ) const
overridevirtual

◆ GetNumberOfLines()

template<typename TLabel, unsigned int VImageDimension>
SizeValueType itk::LabelObject< TLabel, VImageDimension >::GetNumberOfLines ( ) const

◆ HasIndex()

template<typename TLabel, unsigned int VImageDimension>
bool itk::LabelObject< TLabel, VImageDimension >::HasIndex ( const IndexType idx) const

Return true if the object contain the given index and false otherwise. Worst case complexity is O(L) where L is the number of lines in the object.

◆ New()

template<typename TLabel, unsigned int VImageDimension>
static Pointer itk::LabelObject< TLabel, VImageDimension >::New ( )
static

Method for creation through the object factory.

◆ Optimize()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::Optimize ( )

Reorder the lines, merge the touching lines and ensure that no pixel is covered by two lines

◆ PrintSelf()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from itk::LightObject.

Reimplemented in itk::ShapeLabelObject< TLabel, VImageDimension >, and itk::StatisticsLabelObject< TLabel, VImageDimension >.

◆ RemoveIndex()

template<typename TLabel, unsigned int VImageDimension>
bool itk::LabelObject< TLabel, VImageDimension >::RemoveIndex ( const IndexType idx)

Remove an index to the object. Depending on the configuration, it can either reduce the size of the corresponding line, add one more line, remove the line from the line container.

◆ SetLabel()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::SetLabel ( const LabelType label)

◆ Shift()

template<typename TLabel, unsigned int VImageDimension>
void itk::LabelObject< TLabel, VImageDimension >::Shift ( OffsetType  offset)

Shift the object position

◆ Size()

template<typename TLabel, unsigned int VImageDimension>
SizeValueType itk::LabelObject< TLabel, VImageDimension >::Size ( ) const

Returns the number of pixels contained in the object.

Warning
To get an accurate result, you need to make sure there is no duplication in the line container. One way to ensure this (at a cost) is to call the Optimize method.

Member Data Documentation

◆ ImageDimension

template<typename TLabel, unsigned int VImageDimension>
constexpr unsigned int itk::LabelObject< TLabel, VImageDimension >::ImageDimension = VImageDimension
staticconstexpr

Definition at line 85 of file itkLabelObject.h.

◆ LABEL

template<typename TLabel, unsigned int VImageDimension>
constexpr AttributeType itk::LabelObject< TLabel, VImageDimension >::LABEL = 0
staticconstexpr

Definition at line 95 of file itkLabelObject.h.

◆ m_Label

template<typename TLabel, unsigned int VImageDimension>
LabelType itk::LabelObject< TLabel, VImageDimension >::m_Label {}
private

Definition at line 411 of file itkLabelObject.h.

◆ m_LineContainer

template<typename TLabel, unsigned int VImageDimension>
LineContainerType itk::LabelObject< TLabel, VImageDimension >::m_LineContainer {}
private

Definition at line 410 of file itkLabelObject.h.


The documentation for this class was generated from the following file: