ImFusion SDK 4.3
Mask Class Referenceabstract

#include <ImFusion/Base/Mask.h>

Base interface for implementing polymorphic image masks on the CPU. More...

+ Inheritance diagram for Mask:

Detailed Description

Base interface for implementing polymorphic image masks on the CPU.

Every SharedImage can hold an optional Mask defining which pixels should be ignored in algorithms supporting this concept. Therefore, the interface provides methods to check whether a certain pixel is "inside" the mask (meaning that it should be considered) or not. The decision whether a pixel is inside can be performed based on the pixel coordinate and/or the pixel value. The actual logic for the mask depends on the concrete implementation of the interface and subclasses are free to only use one of the two inputs if sufficient.

A mask value of 0 means the corresponding pixel is outside the mask, i.e. to be ignored. A value greater than 0 means it is inside, i.e. to be considered. Most mask will only return binary values of 0 and 1 but implementations are free to return any other uint8_t value as well.

The basic Mask interface is meant for CPU-based algorithms only. See GlMask for their OpenGL-based counterpart. Usually, concrete implementations inherit from both the Mask and GlMask interfaces.

See also
Image Masks, GlMask

Public Types

enum class  CreateOption { DeepCopy , ShallowCopyIfPossible }
 Enumeration of available behavior for createExplicitMask() More...
 

Public Member Functions

virtual uint8_t maskValue (const vec3i &coord, const vec4f &color) const =0
 Returns 0 if the given pixel is outside the mask (i.e.
 
uint8_t maskValue (const vec3i &coord, float value=-1.0f) const
 Convenience overload that calls maskValue(coord, vec4f(value, value, value, 1.0f)).
 
virtual bool requiresPixelValue () const =0
 Returns true if the maskValue() rely on the pixel value.
 
virtual bool isCompatible (const SharedImage *image) const =0
 Returns true if the mask can be used with the given image or false otherwise.
 
virtual std::unique_ptr< TypedImage< uint8_t > > createExplicitMask (const SharedImage &image, CreateOption createOption=CreateOption::DeepCopy) const
 Creates an explicit mask representation of this mask for a given image.
 
virtual std::unique_ptr< MaskresizedMask (const SharedImage &original, const Image &target) const
 Creates a copy of the current mask, resized to the dimensions of the target image.
 
virtual GlMaskglMask ()
 Returns the OpenGL-based implementation of the mask interface if available.
 
- Public Member Functions inherited from Configurable
virtual void configure (const Properties *p)
 Configure this object instance by de-serializing the given Properties.
 
virtual void configuration (Properties *p) const
 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
 
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.
 

Member Enumeration Documentation

◆ CreateOption

enum class CreateOption
strong

Enumeration of available behavior for createExplicitMask()

Enumerator
DeepCopy 

Always create a full deep copy of the mask data.

ShallowCopyIfPossible 

If the input mask already has a suitable image representation of the explicit mask, it will return a shallow copy of the pixel data.

Member Function Documentation

◆ maskValue()

virtual uint8_t maskValue ( const vec3i & coord,
const vec4f & color ) const
pure virtual

Returns 0 if the given pixel is outside the mask (i.e.

invisible/to be ignored) or a non-zero value if it is inside the mask (i.e. visible/to be considered).

This function takes both the pixel coordinate and pixel value as input. Concrete implementations of the Mask interface are free to use only either input for their decision if it makes sense. Also, it is up to the implementation whether it supports multi-channel images or not. Subclasses only supporting grayscale images should only use the first channel.

Parameters
coordPixel coordinate to be tested against the mask, can be outside of the image.
colorPixel value (not normalized) to be tested against the mask. This parameter is only needed if requiresPixelValue() returns true, which can allow for optimizations where pixel lookup is expensive.

Implemented in CroppingMask, ExplicitIntensityMask, ExplicitMask, OperandMask< T >, IntensityMask, SkippingMask, and FanMask.

◆ requiresPixelValue()

virtual bool requiresPixelValue ( ) const
pure virtual

Returns true if the maskValue() rely on the pixel value.

If this method returns false, the maskValue() method can be safely used with only the coordinate. This is useful to avoid an otherwise unnecessary and expensive pixel lookup.

Implemented in CroppingMask, ExplicitIntensityMask, ExplicitMask, OperandMask< T >, IntensityMask, SkippingMask, and FanMask.

◆ isCompatible()

virtual bool isCompatible ( const SharedImage * image) const
pure virtual

Returns true if the mask can be used with the given image or false otherwise.

Implemented in CroppingMask, ExplicitIntensityMask, ExplicitMask, OperandMask< T >, IntensityMask, SkippingMask, and FanMask.

◆ createExplicitMask()

virtual std::unique_ptr< TypedImage< uint8_t > > createExplicitMask ( const SharedImage & image,
CreateOption createOption = CreateOption::DeepCopy ) const
virtual

Creates an explicit mask representation of this mask for a given image.

Parameters
imageReference image for which to create the mask, must be compatible.
createOptionSubclasses that already store an explicit representation of the mask can optionally return a non-owning TypedImage (shallow copy). If the returned TypedImage will outlive the source Mask, make sure to use CreateOption::DeepCopy.

Reimplemented in CroppingMask, ExplicitIntensityMask, and ExplicitMask.

◆ resizedMask()

virtual std::unique_ptr< Mask > resizedMask ( const SharedImage & original,
const Image & target ) const
virtual

Creates a copy of the current mask, resized to the dimensions of the target image.

The default implementation calls createExplicitMask and resamples the result. Returns nullptr if the mask cannot be resized.

Reimplemented in CroppingMask, and IntensityMask.

◆ glMask()

virtual GlMask * glMask ( )
inlinevirtual

Returns the OpenGL-based implementation of the mask interface if available.

This function may return nullptr if this is not implemented (default).

Reimplemented in CroppingMask, ExplicitIntensityMask, ExplicitMask, OperandMask< T >, IntensityMask, SkippingMask, and FanMask.


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