ImFusion SDK 4.3
LabelDataComponent Class Reference

#include <ImFusion/Base/LabelDataComponent.h>

DataComponent to store meta data of a label map. More...

+ Inheritance diagram for LabelDataComponent:

Detailed Description

DataComponent to store meta data of a label map.

Label maps are assumed to be always of type unsigned char, thus there is a maximum of 255 different labels since the value 0 is considered background. The set of labels is stored in a LabelConfig map storing metadata (e.g. name, color, visibility, ...) for each known label.

LabelDataComponent offers helper methods to provide windowing information and color maps that can be used for rendering label maps. They will cover the entire unsigned char value range and use the default color/visibility for unconfigured label values.

By default, labels are considered to be exclusive, which means that every pixel of the underlying label map image corresponds to exactly one of the known LabelConfigs. Special use cases may use the LabelOverlapEncoder interface to define storage value representing multiple overlapping label configs. However, be advised that this is an optional and experimental extension and algorithms are not required to handle such values correctly.

See also
Data::Modality::LABEL, LabelDataComponentWidget

Classes

struct  LabelConfig
 Helper struct encapsulating the metadata of a label value. More...
 

Public Types

enum class  SegmentationAlgorithmType { Unknown , Automatic , SemiAutomatic , Manual }
 Type of algorithm used to generate the segment. More...
 

Public Member Functions

 LabelDataComponent (const SharedImageSet *labelMap=nullptr)
 Instantiate a new LabelDataComponent.
 
 LabelDataComponent (const LabelDataComponent &rhs)
 
LabelDataComponentoperator= (const LabelDataComponent &rhs)
 
bool operator== (const LabelDataComponent &rhs) const
 
Data::Modality sourceModality () const
 Returns the modality the label map is based on.
 
void setSourceModality (Data::Modality value)
 Sets the modality the label map is based on.
 
std::string id () const override
 Returns a unique string identifier for this type of data component.
 
void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
 
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
 
- Public Member Functions inherited from DataComponent< LabelDataComponent >
std::unique_ptr< DataComponentBaseclone () const override
 Creates a clone of this data component.
 
std::unique_ptr< SubclasscloneDerived () const
 
bool assign (const DataComponentBase &other) override
 Assigns the content of other to this data component.
 
bool equals (const DataComponentBase &other) const override
 Compares this data component to other for equality.
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Static Public Member Functions

static LabelConfig defaultLabelConfig (int pixelValue)
 Returns a high-level default label configuration for the given pixel value:
 
- Static Public Member Functions inherited from LazyInstantiatedDataComponent< LabelDataComponent, SharedImageSet >
static LabelDataComponentget (const SharedImageSet &data)
 Returns the specific options of type T that are associated with the given data.
 
static LabelDataComponentget (const SharedImageSet *data)
 

Public Attributes

Signal< LabelDataComponent * > signalChanged
 Signal emitted if any setting of this DataComponent has changed;.
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Functions to get/set the label configuration

const std::map< int, LabelConfig > & labelConfigs () const
 Returns the map of known label configurations.
 
void setLabelConfigs (std::map< int, LabelConfig > labelConfigs)
 Sets the map of known label configurations.
 
std::optional< LabelConfiglabelConfig (int pixelValue) const
 Returns the label configuration for the given pixel value if existent.
 
void setLabelConfig (int pixelValue, const LabelConfig &labelConfig)
 Sets the given label configuration for the given pixel value.
 
void setDefaultLabelConfig (int pixelValue)
 Sets the default label configuration for the given pixel value.
 
bool hasLabel (int pixelValue) const
 Returns true if a label configuration exists for the given pixel value.
 
void removeLabel (int pixelValue)
 Removes the label configuration for the given pixel value if existent.
 
void setLabelColor (int labelValue, const vec4 &color)
 Sets the label color to use for the value labelValue, will create a new default LabelConfig if needed.
 
void setVisibility2d (int labelValue, bool isVisible)
 Sets whether to show the label with value labelValue in 2D views, will create a new default LabelConfig if needed.
 
void setVisibility3d (int labelValue, bool isVisible)
 Sets whether to show the label with value labelValue in 3D views, will create a new default LabelConfig if needed.
 
void setLabelName (int labelValue, const std::string &name)
 Sets the label name for the value labelValue, will create a new default LabelConfig if needed.
 

Utility functions to derive label configuration from a given label map

void detectLabels (const SharedImageSet &sis)
 Checks the pixel intensities present in the given image(s) and creates a new default label configuration for each label that does not yet exist.
 
void removeUnusedLabels (const SharedImageSet &sis)
 Checks the pixel intensities present in the given image(s) and removes all label configurations for non-existing pixel values.
 

Experimental support for overlapping label maps

LabelOverlapEncoderoverlapEncoder () const
 Returns the overlap encoder instance if available.
 
void setOverlapEncoder (std::unique_ptr< LabelOverlapEncoder > encoder)
 Sets an overlap encoder instance to add support for overlapping label values.
 
std::vector< std::unique_ptr< SharedImageSet > > convertOverlapEncoderToLayers (const SharedImageSet &labelmap) const
 Converts the given labelmap with overlapping labels into multiple layers without overlap.
 

Properties and helper functions for rendering label maps

const SharedImagecolormap2d () const
 Returns the color map with 2d label visibility to use for rendering the label map.
 
const SharedImagecolormap3d () const
 Returns the color map with 3d label visibility to use for rendering the label map.
 
vec2 windowLevelNormalized (const ImageDescriptor &img) const
 Returns window/level configuration to use the color map for the given image.
 
vec2 windowLevelNormalized (const Image &img) const
 
vec2 opaqueRange3d () const
 Returns the of intensities where the labels are visible in 3d.
 

Additional Inherited Members

- Protected Member Functions inherited from DataComponentBase
 DataComponentBase (const DataComponentBase &)=default
 
DataComponentBaseoperator= (const DataComponentBase &other)=default
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Member Enumeration Documentation

◆ SegmentationAlgorithmType

enum class SegmentationAlgorithmType
strong

Type of algorithm used to generate the segment.

Enumerator
Unknown 

Unknown.

Automatic 

Label calculated fully automatically.

SemiAutomatic 

Label calculated with user assistance.

Manual 

Label defined fully manually.

Constructor & Destructor Documentation

◆ LabelDataComponent()

LabelDataComponent ( const SharedImageSet * labelMap = nullptr)
explicit

Instantiate a new LabelDataComponent.

Parameters
labelMapOptional pointer to the underlying label map. If not null, will call detectLabels() to create a default LabelConfig for each label value present in labelMap.
Note
The images are expected to be of type unsigned char.

Member Function Documentation

◆ defaultLabelConfig()

static LabelConfig defaultLabelConfig ( int pixelValue)
static

Returns a high-level default label configuration for the given pixel value:

  • if pixelValue is 0: LabelConfig{"Background", vec4(0, 0, 0, 1), false, false} / - if \a pixelValue is i > 0:LabelConfig{"Label i", defaultColor(i)}

◆ setDefaultLabelConfig()

void setDefaultLabelConfig ( int pixelValue)

Sets the default label configuration for the given pixel value.

This is a convenience function with the same effect as setLabelConfig(pixelValue, defaultLabelConfig(pixelValue)).

◆ detectLabels()

void detectLabels ( const SharedImageSet & sis)

Checks the pixel intensities present in the given image(s) and creates a new default label configuration for each label that does not yet exist.

Note
The images are expected to be of type unsigned char.

◆ removeUnusedLabels()

void removeUnusedLabels ( const SharedImageSet & sis)

Checks the pixel intensities present in the given image(s) and removes all label configurations for non-existing pixel values.

Note
The images are expected to be of type unsigned char.

◆ convertOverlapEncoderToLayers()

std::vector< std::unique_ptr< SharedImageSet > > convertOverlapEncoderToLayers ( const SharedImageSet & labelmap) const

Converts the given labelmap with overlapping labels into multiple layers without overlap.

If no overlapEncoder is set or the encoder does not contain any overlaps, an empty list is returned. The number of returned layers depends on the number of overlaps. Which labels end up in which layer is unspecified. The resulting layers will also contain a LabelDataComponent with only the labels present in this layer.

See also
LabelOverlapToLayersAlgorithm

◆ id()

std::string id ( ) const
overridevirtual

Returns a unique string identifier for this type of data component.

Note
To avoid conflicts make sure to include potential plugin names into this ID. Due to the modular architecture of the ImFusion library, uniqueness of IDs cannot be checked at compile time. However, DataComponentFactory will check the uniqueness of the ID during registration.

Implements DataComponentBase.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from Configurable.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close