ImFusion SDK 4.3
LabelOverlapEncoder Class Reference

#include <ImFusion/Base/LabelOverlapEncoder.h>

Helper class to encode overlapping labels into an 8bit label map. More...

+ Inheritance diagram for LabelOverlapEncoder:

Detailed Description

Helper class to encode overlapping labels into an 8bit label map.

Assigns 8bit pixel (storage) values to one or more label values in the range [1,255]. Will treat 0 as reserved pixel value for the empty background. The caller is responsible for ensuring the number of label combinations does not exceed 255, which can be checked via the return values of addLabel or bitfieldAsPixelValue.

Warning
Overlapping label maps are still an experimental feature. This means that many algorithms will not handle such label maps correctly and the API of this extension may change significantly in the future.
See also
Data::Modality::LABEL

Public Member Functions

 LabelOverlapEncoder (const TypedImage< unsigned char > *labelMap=nullptr)
 If an image is passed, it is assumed to not have overlaps yet and a configuration for its pixel values is created.
 
 LabelOverlapEncoder (const LabelOverlapEncoder &)=default
 
LabelOverlapEncoderoperator= (const LabelOverlapEncoder &)=default
 
bool operator== (const LabelOverlapEncoder &other) const
 
bool operator!= (const LabelOverlapEncoder &other) const
 
std::vector< unsigned char > labelValues (unsigned char pixelValue) const
 Returns list of labels corresponding to pixel value > 0.
 
std::vector< unsigned char > labelValues () const
 Returns list of all label values.
 
std::bitset< 256 > labelValuesAsBitfield (unsigned char pixelValue) const
 Returns labels corresponding to pixel value as bitfield, for use in performance critical parts.
 
std::vector< unsigned char > pixelValuesContainingLabel (unsigned char labelValue) const
 Returns a list of pixel values the given label value is included in.
 
unsigned char bitfieldAsPixelValue (const std::bitset< 256 > &bitfield)
 Returns pixel value corresponding to bitfield encoding a label value combination.
 
unsigned char addLabel (unsigned char pixelValue, unsigned char addedLabelValue)
 Adds a label to the pixel, returning the new pixel value.
 
void setPixelValue (unsigned char pixelValue, const std::bitset< 256 > &labelValuesAsBitfield)
 Manually set a specific pixel value for a given label combination.
 
unsigned char numberPixelValues () const
 Returns number of non-zero pixel values used, including those for pure label values.
 
unsigned char numberLabelValues () const
 Returns number of label values used (individual values, not combinations)
 
bool containsOverlaps () const
 Returns whether any of the currently configured pixel values contain overlaps.
 
bool isOverlap (unsigned char pixelValue) const
 Returns whether the given pixel value includes multiple label values.
 
virtual void configure (const Properties *) override
 Configure this object instance by de-serializing the given Properties.
 
virtual void configuration (Properties *) const override
 Serialize the current object configuration into the given Properties object.
 
- 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
 

Additional Inherited Members

- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Constructor & Destructor Documentation

◆ LabelOverlapEncoder()

LabelOverlapEncoder ( const TypedImage< unsigned char > * labelMap = nullptr)

If an image is passed, it is assumed to not have overlaps yet and a configuration for its pixel values is created.

Otherwise you can use the Configurable interface or setPixelValue to set up pixel values.

Member Function Documentation

◆ bitfieldAsPixelValue()

unsigned char bitfieldAsPixelValue ( const std::bitset< 256 > & bitfield)

Returns pixel value corresponding to bitfield encoding a label value combination.

If the passed combination does not have an associated pixel value yet, it attempts to create a new one. When out of possible pixel values the result is 0 and the combination will remain invalid.

◆ addLabel()

unsigned char addLabel ( unsigned char pixelValue,
unsigned char addedLabelValue )

Adds a label to the pixel, returning the new pixel value.

When out of possible pixel values the result is 0 and the combination will remain invalid.

◆ setPixelValue()

void setPixelValue ( unsigned char pixelValue,
const std::bitset< 256 > & labelValuesAsBitfield )

Manually set a specific pixel value for a given label combination.

If this combination already had a pixel value or the pixel value was associated with another combination, this information is discarded. Caller is responsible for making sure the final state of this object contains all required combinations.

◆ configure()

virtual 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()

virtual 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