ITK  4.0.0
Insight Segmentation and Registration Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
itk::LabelMap< TLabelObject > Class Template Reference

Templated n-dimensional image to store labeled objects. More...

#include <itkLabelMap.h>

Inheritance diagram for itk::LabelMap< TLabelObject >:
Collaboration diagram for itk::LabelMap< TLabelObject >:

List of all members.

Classes

class  ConstIterator
 A forward iterator over the LabelObjects of a LabelMap. More...
class  Iterator
 A forward iterator over the LabelObjects of a LabelMap. More...

Public Types

typedef SmartPointer< const SelfConstPointer
typedef WeakPointer< const SelfConstWeakPointer
typedef Superclass::DirectionType DirectionType
typedef Superclass::IndexType IndexType
typedef LabelObjectType::Pointer LabelObjectPointerType
typedef TLabelObject LabelObjectType
typedef std::vector
< LabelObjectPointerType
LabelObjectVectorType
typedef LabelObjectType::LabelType LabelType
typedef std::vector< LabelTypeLabelVectorType
typedef SizeValueType LengthType
typedef Superclass::OffsetType OffsetType
typedef Superclass::OffsetValueType OffsetValueType
typedef LabelType PixelType
typedef SmartPointer< SelfPointer
typedef Superclass::PointType PointType
typedef Superclass::RegionType RegionType
typedef LabelMap Self
typedef Superclass::SizeType SizeType
typedef Superclass::SizeValueType SizeValueType
typedef Superclass::SpacingType SpacingType
typedef ImageBase
< ::itk::GetImageDimension
< TLabelObject >
::ImageDimension
Superclass

Public Member Functions

void AddLabelObject (LabelObjectType *labelObject)
void AddPixel (const IndexType &idx, const LabelType &label)
virtual void Allocate ()
void ClearLabels ()
virtual ::itk::LightObject::Pointer CreateAnother (void) const
LabelObjectTypeGetLabelObject (const IndexType &idx) const
LabelObjectVectorType GetLabelObjects () const
LabelVectorType GetLabels () const
virtual const char * GetNameOfClass () const
Self::SizeValueType GetNumberOfLabelObjects () const
const LabelTypeGetPixel (const IndexType &idx) const
virtual void Graft (const DataObject *data)
bool HasLabel (const LabelType label) const
virtual void Initialize ()
void Optimize ()
void PrintLabelObjects () const
void PrintLabelObjects (std::ostream &os) const
void PushLabelObject (LabelObjectType *labelObject)
void RemoveLabel (const LabelType &label)
void RemoveLabelObject (LabelObjectType *labelObject)
void RemovePixel (const IndexType &idx, const LabelType &label)
void SetLine (const IndexType &idx, const LengthType &length, const LabelType &label)
void SetPixel (const IndexType &idx, const LabelType &label)
void SetRegions (const SizeType &size)
void SetRegions (const RegionType &region)
LabelObjectTypeGetLabelObject (const LabelType &label)
const LabelObjectTypeGetLabelObject (const LabelType &label) const
LabelObjectTypeGetNthLabelObject (const SizeValueType &pos)
const LabelObjectTypeGetNthLabelObject (const SizeValueType &pos) const
virtual LabelType GetBackgroundValue () const
virtual void SetBackgroundValue (LabelType _arg)

Static Public Member Functions

static Pointer New ()

Static Public Attributes

static const unsigned int ImageDimension = LabelObjectType::ImageDimension

Protected Member Functions

 LabelMap ()
void PrintSelf (std::ostream &os, Indent indent) const
virtual ~LabelMap ()

Private Types

typedef
LabelObjectContainerType::const_iterator 
LabelObjectContainerConstIterator
typedef
LabelObjectContainerType::iterator 
LabelObjectContainerIterator
typedef std::map< LabelType,
LabelObjectPointerType
LabelObjectContainerType

Private Member Functions

void AddPixel (const LabelObjectContainerIterator &it, const IndexType &idx, const LabelType &iLabel)
 LabelMap (const Self &)
void operator= (const Self &)
void RemovePixel (const LabelObjectContainerIterator &it, const IndexType &idx, bool iEmitModifiedEvent)

Private Attributes

LabelType m_BackgroundValue
LabelObjectContainerType m_LabelObjectContainer

Detailed Description

template<class TLabelObject>
class itk::LabelMap< TLabelObject >

Templated n-dimensional image to store labeled objects.

LabelMap is an image class specialized in storing the labeled images. It represent the image in a different way than itk::Image. Instead of storing the content of the image in an array of pixels values, it store the a collection of labeled objects, and a background value. This way of storing the content of the image allow an easy and efficient manipulation of the objects in the image.

The LabelMap shares a lot of methods with the itk::Image class. it make it usable as input or output of the itk::ImageToImageFilter for example. However the methods don't have the same complexity in the 2 classes, because of the different way to store the data. GetPixel() is run in constant time for example in itk::Image, but have a worst case complexity of O(L), where L is the number of lines in the image (imageSize[1] * imageSize[2] for a 3D image).

To iterate over the LabelObjects in the map, use:

 for(unsigned int i = 0; i < filter->GetOutput()->GetNumberOfLabelObjects(); ++i)
   {
   FilterType::OutputImageType::LabelObjectType* labelObject =
     filter->GetOutput()->GetNthLabelObject(i);
   }
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: http://hdl.handle.net/1926/584 or http://www.insight-journal.org/browse/publication/176

Wiki Examples:

Definition at line 70 of file itkLabelMap.h.


Member Typedef Documentation

template<class TLabelObject >
typedef SmartPointer< const Self > itk::LabelMap< TLabelObject >::ConstPointer
template<class TLabelObject >
typedef WeakPointer< const Self > itk::LabelMap< TLabelObject >::ConstWeakPointer

Definition at line 78 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::DirectionType itk::LabelMap< TLabelObject >::DirectionType

Direction typedef support. A matrix of direction cosines.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 117 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::IndexType itk::LabelMap< TLabelObject >::IndexType

Index typedef support. An index is used to access pixel values.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 108 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelObjectContainerType::const_iterator itk::LabelMap< TLabelObject >::LabelObjectContainerConstIterator [private]

Definition at line 484 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelObjectContainerType::iterator itk::LabelMap< TLabelObject >::LabelObjectContainerIterator [private]

Definition at line 482 of file itkLabelMap.h.

template<class TLabelObject >
typedef std::map< LabelType, LabelObjectPointerType > itk::LabelMap< TLabelObject >::LabelObjectContainerType [private]

the LabelObject container type

Definition at line 481 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelObjectType::Pointer itk::LabelMap< TLabelObject >::LabelObjectPointerType

Definition at line 88 of file itkLabelMap.h.

template<class TLabelObject >
typedef TLabelObject itk::LabelMap< TLabelObject >::LabelObjectType

Definition at line 84 of file itkLabelMap.h.

template<class TLabelObject >
typedef std::vector< LabelObjectPointerType > itk::LabelMap< TLabelObject >::LabelObjectVectorType

Definition at line 105 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelObjectType::LabelType itk::LabelMap< TLabelObject >::LabelType

Label typedef support.

Definition at line 100 of file itkLabelMap.h.

template<class TLabelObject >
typedef std::vector< LabelType > itk::LabelMap< TLabelObject >::LabelVectorType

types used to expose labels only and label objects only

Definition at line 104 of file itkLabelMap.h.

template<class TLabelObject >
typedef SizeValueType itk::LabelMap< TLabelObject >::LengthType

Definition at line 91 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::OffsetType itk::LabelMap< TLabelObject >::OffsetType

Offset typedef support. An offset is used to access pixel values.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 111 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::OffsetValueType itk::LabelMap< TLabelObject >::OffsetValueType

Offset typedef (relative position between indices)

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 132 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelType itk::LabelMap< TLabelObject >::PixelType

Definition at line 101 of file itkLabelMap.h.

template<class TLabelObject >
typedef SmartPointer< Self > itk::LabelMap< TLabelObject >::Pointer
template<class TLabelObject >
typedef Superclass::PointType itk::LabelMap< TLabelObject >::PointType

Origin typedef support. The origin is the geometric coordinates of the index (0,0).

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 129 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::RegionType itk::LabelMap< TLabelObject >::RegionType

Region typedef support. A region is used to specify a subset of an image.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 121 of file itkLabelMap.h.

template<class TLabelObject >
typedef LabelMap itk::LabelMap< TLabelObject >::Self

Standard class typedefs

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 74 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::SizeType itk::LabelMap< TLabelObject >::SizeType

Size typedef support. A size is used to define region bounds.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 114 of file itkLabelMap.h.

template<class TLabelObject >
typedef Superclass::SizeValueType itk::LabelMap< TLabelObject >::SizeValueType
template<class TLabelObject >
typedef Superclass::SpacingType itk::LabelMap< TLabelObject >::SpacingType

Spacing typedef support. Spacing holds the size of a pixel. The spacing is the geometric distance between image samples.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 125 of file itkLabelMap.h.

template<class TLabelObject >
typedef ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension > itk::LabelMap< TLabelObject >::Superclass

Constructor & Destructor Documentation

template<class TLabelObject >
itk::LabelMap< TLabelObject >::LabelMap ( ) [protected]
template<class TLabelObject >
virtual itk::LabelMap< TLabelObject >::~LabelMap ( ) [inline, protected, virtual]

Definition at line 473 of file itkLabelMap.h.

template<class TLabelObject >
itk::LabelMap< TLabelObject >::LabelMap ( const Self ) [private]

Member Function Documentation

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::AddLabelObject ( LabelObjectType labelObject)

Add a label object to the image. If a label object already has the label, it is overiden.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::AddPixel ( const IndexType idx,
const LabelType label 
)

Add index idx to the label object whose label is label. If no label object has the label label, the corresponding label object is created. The worst case complexity of this method is O(L) where L is the number of lines in the image. However, the execution time will be quite low if the pixels are set in the image in raster mode.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::AddPixel ( const LabelObjectContainerIterator it,
const IndexType idx,
const LabelType iLabel 
) [private]
template<class TLabelObject >
virtual void itk::LabelMap< TLabelObject >::Allocate ( ) [virtual]
template<class TLabelObject >
void itk::LabelMap< TLabelObject >::ClearLabels ( )

Remove all the labels in the image

template<class TLabelObject >
virtual::itk::LightObject::Pointer itk::LabelMap< TLabelObject >::CreateAnother ( void  ) const [virtual]

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
virtual LabelType itk::LabelMap< TLabelObject >::GetBackgroundValue ( ) const [virtual]

Set/Get the background label

template<class TLabelObject >
LabelObjectType* itk::LabelMap< TLabelObject >::GetLabelObject ( const LabelType label)

Return the LabelObject with the label given in parameter. This method thorws an exception if the label doesn't exist in this image, or if the label is the background one.

template<class TLabelObject >
LabelObjectType* itk::LabelMap< TLabelObject >::GetLabelObject ( const IndexType idx) const

Return the label object at a given index. This method has a worst case complexity of O(L) where L is the number of lines in the image - use it with care.

template<class TLabelObject >
const LabelObjectType* itk::LabelMap< TLabelObject >::GetLabelObject ( const LabelType label) const

Return the LabelObject with the label given in parameter. This method thorws an exception if the label doesn't exist in this image, or if the label is the background one.

template<class TLabelObject >
LabelObjectVectorType itk::LabelMap< TLabelObject >::GetLabelObjects ( ) const

Return the the label objects available in the label map

template<class TLabelObject >
LabelVectorType itk::LabelMap< TLabelObject >::GetLabels ( ) const

Return the labels of the label objects available in the label map

template<class TLabelObject >
virtual const char* itk::LabelMap< TLabelObject >::GetNameOfClass ( ) const [virtual]

Run-time type information (and related methods).

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
LabelObjectType* itk::LabelMap< TLabelObject >::GetNthLabelObject ( const SizeValueType pos)

Return the LabelObject with at the position given in parameter. This method can be useful when the labels are not consecutives, but is quite inefficient. This method thorws an exception if the index doesn't exist in this image.

template<class TLabelObject >
const LabelObjectType* itk::LabelMap< TLabelObject >::GetNthLabelObject ( const SizeValueType pos) const

Return the LabelObject with at the position given in parameter. This method can be useful when the labels are not consecutives, but is quite inefficient. This method thorws an exception if the index doesn't exist in this image.

template<class TLabelObject >
Self::SizeValueType itk::LabelMap< TLabelObject >::GetNumberOfLabelObjects ( ) const

Return the numbner of label objects in the image

template<class TLabelObject >
const LabelType& itk::LabelMap< TLabelObject >::GetPixel ( const IndexType idx) const

Return the pixel value at a given index in the image. If the given index is contained in several objects, only the smallest label of those objects is returned. This method has a worst case complexity of O(L) where L is the number of lines in the image - use it with care.

template<class TLabelObject >
virtual void itk::LabelMap< TLabelObject >::Graft ( const DataObject data) [virtual]

Graft the data and information from one image to another. This is a convenience method to setup a second image with all the meta information of another image and use the same pixel container. Note that this method is different than just using two SmartPointers to the same image since separate DataObjects are still maintained. This method is similar to ImageSource::GraftOutput(). The implementation in ImageBase simply calls CopyInformation() and copies the region ivars. Subclasses of ImageBase are responsible for copying the pixel container.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
bool itk::LabelMap< TLabelObject >::HasLabel ( const LabelType  label) const

Return true is the image contains the label given in parameter and false otherwise. If the label is the background one, true is also returned, so this method may not be a good enough test before calling GetLabelObject().

template<class TLabelObject >
virtual void itk::LabelMap< TLabelObject >::Initialize ( ) [virtual]

Restore the data object to its initial state. This means releasing memory.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
static Pointer itk::LabelMap< TLabelObject >::New ( ) [static]

Method for creation through the object factory.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::operator= ( const Self ) [private]
template<class TLabelObject >
void itk::LabelMap< TLabelObject >::Optimize ( )

Optimize the line representation of all the lable objects referenced in the LabelMap

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::PrintLabelObjects ( ) const [inline]

Definition at line 295 of file itkLabelMap.h.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::PrintLabelObjects ( std::ostream &  os) const

Print all the objects stored in that collection - a convenient method for prototyping.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const [protected, virtual]

Method for grafting the content of one data object into another one. This method is intended to be overloaded by derived classes. Each one of them should use dynamic_casting in order to verify that the grafted object is actually of the same type as the class on which the Graft() method was invoked.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::PushLabelObject ( LabelObjectType labelObject)

Add a label object to the image. The label of the label object is ignored, and a new label is given to the label object.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::RemoveLabel ( const LabelType label)

Remove a label object.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::RemoveLabelObject ( LabelObjectType labelObject)

Remove a label object.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::RemovePixel ( const IndexType idx,
const LabelType label 
)

Remove index idx from the label object which has the label label. If the label object gets empty, it is being removed from the container.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::RemovePixel ( const LabelObjectContainerIterator it,
const IndexType idx,
bool  iEmitModifiedEvent 
) [private]
template<class TLabelObject >
virtual void itk::LabelMap< TLabelObject >::SetBackgroundValue ( LabelType  _arg) [virtual]

Set/Get the background label

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::SetLine ( const IndexType idx,
const LengthType length,
const LabelType label 
)

Set a full line in the image. If no label object has this label in the image, a new object is created. If a label object already exist with that label, the line is added to it WITHOUT any check - it means that if the label object may contain several time the same pixel after have run that method. This method runs in constant time.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::SetPixel ( const IndexType idx,
const LabelType label 
)

Set the pixel value at a given index in the image.

As for itk::Image, this method ensure that the pixel at the position idx has a unique value.

The complexity of this method is at best O(L) where L is the number of lines in the image - usit with care.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::SetRegions ( const SizeType size) [inline]

Definition at line 145 of file itkLabelMap.h.

template<class TLabelObject >
void itk::LabelMap< TLabelObject >::SetRegions ( const RegionType region) [inline]

Convenience methods to set the LargestPossibleRegion, BufferedRegion and RequestedRegion. Allocate must still be called.

Definition at line 137 of file itkLabelMap.h.


Member Data Documentation

template<class TLabelObject >
const unsigned int itk::LabelMap< TLabelObject >::ImageDimension = LabelObjectType::ImageDimension [static]

Dimension of the image. This constant is used by functions that are templated over image type (as opposed to being templated over pixel type and dimension) when they need compile time access to the dimension of the image.

Reimplemented from itk::ImageBase< ::itk::GetImageDimension< TLabelObject >::ImageDimension >.

Definition at line 97 of file itkLabelMap.h.

template<class TLabelObject >
LabelType itk::LabelMap< TLabelObject >::m_BackgroundValue [private]

Definition at line 487 of file itkLabelMap.h.

template<class TLabelObject >
LabelObjectContainerType itk::LabelMap< TLabelObject >::m_LabelObjectContainer [private]

Definition at line 486 of file itkLabelMap.h.


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