ImFusion C++ SDK 4.4.0
ImFusion::ImageMath::OperandMask< OperandT > Class Template Reference

#include <ImFusion/ImageMath/Tpl/OperandMask.h>

Mask/GlMask from an ImageMath expression. More...

Inheritance diagram for ImFusion::ImageMath::OperandMask< OperandT >:

Detailed Description

template<typename OperandT>
class ImFusion::ImageMath::OperandMask< OperandT >

Mask/GlMask from an ImageMath expression.

The value of the Image at a point is taken via an ImageMath::Variable. As masks get the value in "storage" format, the storage to original conversion must be applied manually. Example:

imgDesc.shift = 1024;
auto mask = (variable.storageToOriginal(imgDesc) > 0.0);
Helper Variable class for use with stashes.
Definition StashTpl.h:26
Struct describing the essential properties of an image.
Definition ImageDescriptor.h:49
double shift
Optional intensity shift wrt. the original image values, cf. Pixel Value Domains.
Definition ImageDescriptor.h:57

The result Mask can be then be added to SharedImage, see SharedImage::setMask.

See also
Mask,
GlMask

Public Member Functions

 OperandMask (const OperandT &operand)
 OperandMask (const OperandMask &other)
unsigned char maskValue (const vec3i &coord, const vec4f &color) const override
 Mask interface.
bool requiresPixelValue () const override
 Returns true if the maskValue() rely on the pixel value.
bool isCompatible (const SharedImage *arg) const override
 Returns true if the mask can be used with the given image or false otherwise.
GlMaskglMask () override
 Returns the OpenGL-based implementation of the mask interface if available.
std::vector< GL::AbstractInclude * > dependentIncludes () const override
 GlMask Interface.
int setIncludeArguments (GL::Program &p, const std::string &prefix="mask") const override
 Called by users of GlMask in order to correctly setup the mask shader.
internal::GlExprInterfaceoperand () override
const internal::GlExprInterfaceoperand () const override
const OperandT & operandRaw () const
Public Member Functions inherited from ImFusion::Mask
uint8_t maskValue (const vec3i &coord, float value=-1.0f) const
 Convenience overload that calls maskValue(coord, vec4f(value, value, value, 1.0f)).
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.
Public Member Functions inherited from ImFusion::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
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept
Public Member Functions inherited from ImFusion::GlMask
 GlMask (const std::string &includePath)
 Instantiates a new GL::AbstractInclude using IMAGE_MASK as defineName and the given path the to retrieve the GLSL source code from.
virtual std::unique_ptr< GlImagecreateExplicitMaskGl (const GlImage &inputImage, bool normalized=false)
 Creates an explicit mask representation of this mask when applied to the given image.
Public Member Functions inherited from ImFusion::GL::AbstractInclude
 AbstractInclude (const std::string &defineName, const std::string &includePath)
 Creates a AbstractInclude for the given define and with the corresponding GLSL file at includePath.
const std::stringdefineName () const
 Returns the name of define used by this include.
const std::stringincludePath () const
 Returns the path to the included shader file.
virtual std::function< std::string(const std::string &)> includeCodeSubstitution () const
 Optionally the abstract include can provide a function to change the shader code.
virtual Fingerprint fingerprint () const
 Provides a finger print of the include.
Public Member Functions inherited from ImFusion::GL::MultiIncludable< GlMask >
std::shared_ptr< MultiIncludeTypecreateMultiInclude (const std::string &replacementToken)
 Instantiates a new AbstractInclude instance where all occurrences of baseToken provided during construction are replaces with replacementToken according to the specified replacementScheme.
virtual int setIncludeArguments (Program &prog, IncludeArgumentsTypes... includeArgs, const std::string &token) const=0
 Interface that multi includes should use to configure the shader include (such as setting uniforms, binding textures, etc).

Additional Inherited Members

Public Types inherited from ImFusion::Mask
enum class  CreateOption { DeepCopy , ShallowCopyIfPossible }
 Enumeration of available behavior for createExplicitMask(). More...
Public Types inherited from ImFusion::GL::MultiIncludable< GlMask >
using MultiIncludeType
 Alias for type of a multi-include instance of the original include.
Static Public Member Functions inherited from ImFusion::GlMask
static std::string defineName ()
 Returns "IMAGE_MASK".
static std::string defineSuffix ()
 Returns "MASK".
static std::string multiIncludeDefine (const std::string &replacementToken)
 Returns "IMAGE_" + toUpper(replacementToken).
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
Protected Member Functions inherited from ImFusion::GL::MultiIncludable< GlMask >
 MultiIncludable (GlMask *crtpInstance, const std::string &baseToken, Flags< ShaderTextReplacement > replacementScheme)
 Instantiate and configure the MultiIncludable interface.
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Member Function Documentation

◆ maskValue()

template<typename OperandT>
unsigned char ImFusion::ImageMath::OperandMask< OperandT >::maskValue ( const vec3i & coord,
const vec4f & color ) const
inlineoverridevirtual

Mask interface.

Implements ImFusion::Mask.

◆ requiresPixelValue()

template<typename OperandT>
bool ImFusion::ImageMath::OperandMask< OperandT >::requiresPixelValue ( ) const
inlineoverridevirtual

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.

Implements ImFusion::Mask.

◆ isCompatible()

template<typename OperandT>
bool ImFusion::ImageMath::OperandMask< OperandT >::isCompatible ( const SharedImage * image) const
inlineoverridevirtual

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

Implements ImFusion::Mask.

◆ glMask()

template<typename OperandT>
GlMask * ImFusion::ImageMath::OperandMask< OperandT >::glMask ( )
inlineoverridevirtual

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

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

Reimplemented from ImFusion::Mask.

◆ dependentIncludes()

template<typename OperandT>
std::vector< GL::AbstractInclude * > ImFusion::ImageMath::OperandMask< OperandT >::dependentIncludes ( ) const
inlineoverridevirtual

GlMask Interface.

Reimplemented from ImFusion::GL::AbstractInclude.

◆ setIncludeArguments()

template<typename OperandT>
int ImFusion::ImageMath::OperandMask< OperandT >::setIncludeArguments ( GL::Program & p,
const std::string & prefix = "mask" ) const
inlineoverridevirtual

Called by users of GlMask in order to correctly setup the mask shader.

Subclasses should implement this function so that it correctly sets all needed uniforms and input textures to be used by the OpenGL shader instance. Make sure to use the given prefix argument instead of a hardcoded "mask" when defining uniform names to support multi-includes where the prefixes have been replaced with unique alternatives. Example:

p.setArgument(prefix + "UseRange", m_useRange);

Implements ImFusion::GlMask.

◆ operand() [1/2]

template<typename OperandT>
internal::GlExprInterface & ImFusion::ImageMath::OperandMask< OperandT >::operand ( )
inlineoverridevirtual

◆ operand() [2/2]

template<typename OperandT>
const internal::GlExprInterface & ImFusion::ImageMath::OperandMask< OperandT >::operand ( ) const
inlineoverridevirtual

The documentation for this class was generated from the following file:
  • ImFusion/ImageMath/Tpl/OperandMask.h
Search Tab / S to search, Esc to close