![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/LabelOverlapEncoder.h>
Helper class to encode overlapping labels into an 8bit label map. More...
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.
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 | |
LabelOverlapEncoder & | operator= (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. | |
![]() | |
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 |
Additional Inherited Members | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
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.
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.
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.
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.
|
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.