![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/LabelDataComponent.h>
DataComponent to store meta data of a label map. More...
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.
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) | |
LabelDataComponent & | operator= (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. | |
![]() | |
std::unique_ptr< DataComponentBase > | clone () const override |
Creates a clone of this data component. | |
std::unique_ptr< Subclass > | cloneDerived () 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. | |
![]() | |
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 | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
Static Public Member Functions | |
static LabelConfig | defaultLabelConfig (int pixelValue) |
Returns a high-level default label configuration for the given pixel value: | |
![]() | |
static LabelDataComponent & | get (const SharedImageSet &data) |
Returns the specific options of type T that are associated with the given data. | |
static LabelDataComponent * | get (const SharedImageSet *data) |
Public Attributes | |
Signal< LabelDataComponent * > | signalChanged |
Signal emitted if any setting of this DataComponent has changed;. | |
![]() | |
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< LabelConfig > | labelConfig (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 | |
LabelOverlapEncoder * | overlapEncoder () 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 SharedImage & | colormap2d () const |
Returns the color map with 2d label visibility to use for rendering the label map. | |
const SharedImage & | colormap3d () 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 | |
![]() | |
DataComponentBase (const DataComponentBase &)=default | |
DataComponentBase & | operator= (const DataComponentBase &other)=default |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
|
strong |
|
explicit |
Instantiate a new LabelDataComponent.
labelMap | Optional pointer to the underlying label map. If not null, will call detectLabels() to create a default LabelConfig for each label value present in labelMap. |
unsigned char
.
|
static |
Returns a high-level default label configuration for the given pixel value:
LabelConfig{"Background", vec4(0, 0, 0, 1), false, false} / - if \a pixelValue is i > 0:
LabelConfig{"Label i", defaultColor(i)} 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))
.
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.
unsigned char
. 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.
unsigned char
. 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.
|
overridevirtual |
Returns a unique string identifier for this type of data component.
Implements DataComponentBase.
|
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.
Reimplemented from Configurable.
|
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.
Reimplemented from Configurable.