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

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

Use a Mask/GlMask as an ImageMath leaf that can be used in ImageMath expressions. More...

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

Detailed Description

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

Use a Mask/GlMask as an ImageMath leaf that can be used in ImageMath expressions.

The "value" parameter for the mask is itself an ImageMath expression.

Warning
GlMasks expect their "value" parameter in normalized storage convention, Masks expect their "value" in storage convention. ImageMath typically works in (unnormalized) original convention,
See also
ImageDescriptor The normalization is performed with the pixelType of the expression's ImageDescriptor, it is the responsibility of the user to verify that this yields something that the mask expects. The original->storage conversion must be performed by the user. Users must be aware of the fact that value domain conversions can result in rounding errors.

Example usage, here si is a SharedImage

m->setRoundness(100);
auto maskLeaf = ImageMath::makeMaskLeaf( ImageMath::makeArray(si), m); // First argument is redundant as CroppingMask doesn't use 'value'
auto derivedExpr = (maskLeaf > 0).select(1.0,2.0);
auto select(const ExprBaseTpl< LhsT > &lhs, const ExprBaseTpl< RhsT > &rhs) const
Definition ExprBaseTpl.h:552
auto makeArray(TypedImage< T > &img, bool ignoreShiftAndScale, MagFilter magFilter, Wrap wrap, const vec4f &borderColor)
Convenience function to create an array leaf (needed as until c++17 there is no template type deducti...
Definition Array.h:664
T make_shared(T... args)
Warning
Using different underlying types or shift+scale values in the operand will give undefined results for masks that depend on the operand.

Public Types

using var_type = typename OperandT::var_type
using expr_type = typename std::conditional<std::is_void_v<typename OperandT::expr_type>, void, double>::type
using imf_img_type = typename OperandT::imf_img_type

Public Member Functions

 MaskLeaf (const OperandT &operand, std::shared_ptr< Mask > mask)
template<typename ImgT>
auto convertToMemImgExpr () const noexcept
auto convertToSharedImgExpr (std::size_t index) const
 SharedImageSet version.
template<typename SubOperandT>
auto substituteVariable (const SubOperandT &operand) const
 Substitutes any Variable leaf.
IMFUSION_STRONG_INLINE expr_type eval (const std::size_t, const vec4i &coord) const
 CPU implementation.
int numImgs () const override
 Return number of images of this expression.
DeviceStrategy deviceStrategy () const override
 Return DeviceStrategy of this expression.
ImageDescriptor imgDesc () const override
 Return ImageDescriptor of this expression. This reference is expected to remain the same while the class exists.
std::vector< internal::GlExprInterface * > children () override
 Used for traversing the expression tree. Contains the immediate children of node.
std::vector< const internal::GlExprInterface * > children () const override
 Used for traversing the expression tree. Contains the immediate children of node.
const std::shared_ptr< Mask > & mask () const override
internal::GlExprInterfaceoperand () override
const internal::GlExprInterfaceoperand () const override
Public Member Functions inherited from ImFusion::ImageMath::ExprBaseTpl< MaskLeaf< OperandT > >
const auto & get () const
 get a const reference to this with the actual type
auto polyWrapper () const
auto uniquePolyWrapper () const
auto sharedPolyWrapper () const
auto binaryOp (const ExprBaseTpl< RhsT > &rhs, const Op &func=Op()) const
auto unaryOp (const Op &func=Op()) const
reduction_type reduce (std::vector< vec4i > *arg=nullptr) const
auto forceCPU () const
 Forces CPU execution.
auto forceGPU () const
 Forces GPU execution.
auto channelSwizzle (const std::vector< std::size_t > &indices) const
auto head ()
 ADD_SPECIAL_SWIZZLE (x, {0})
auto streamChannels (int numStreamedChannels) const
auto substituteVariableWithImg (T &img) const
auto operator- () const
auto cast () const
auto storageToOriginal (const ImageDescriptor &desc)
 Apply shift/scale to the operand,.
auto originalToStorage (const ImageDescriptor &desc)
 Apply shift/scale to the operand,.
auto channelReduction ()
 ADD_CHANNEL_REDUCTION_OPERATOR (channelSum, add)
auto channelMean ()
auto squaredLength () const
auto channelDistance (const ExprBaseTpl< RhsT > &other) const
auto dot (const ExprBaseTpl< RhsT > &other) const
auto stashThenApply (const ExprBaseTpl< VariableT > &varExpr) const
auto hnormalized () const
auto normalized () const
auto homogeneous () const
auto appendZero () const
auto select (const ExprBaseTpl< LhsT > &lhs, const ExprBaseTpl< RhsT > &rhs) const
 Ternary (condition.x ? if_true : if_false) operator.
 ADD_REDUCTION_OPERATOR (sum, add)
 ADD_ARG_REDUCTION_OPERATOR (min, min)
Eigen::Matrix< double, Eigen::Dynamic, 1 > mean () const
Eigen::Matrix< double, Eigen::Dynamic, 1 > l1Norm () const
Eigen::Matrix< double, Eigen::Dynamic, 1 > squaredl2Norm () const
Eigen::Matrix< double, Eigen::Dynamic, 1 > l2Norm () const
Eigen::Matrix< double, Eigen::Dynamic, 1 > lpNorm (double p) const
Eigen::Matrix< double, Eigen::Dynamic, 1 > lInfNorm () const
auto evaluateIntoImage (bool clearShiftScale=false) const
 Create an empty image and evaluate this expression into it.
auto toMask () const
auto toDeformation (const ImageDescriptorWorld imgDesc) const
auto resample (const ImageDescriptorWorld &inputDesc, const ImageDescriptorWorld &outputDesc) const
Public Member Functions inherited from ImFusion::ImageMath::internal::MaskLeafGl
void tagAndAssignNames (std::unordered_map< ImageMath::internal::TaggingIndex, const void * > &taggedLeaves, std::unordered_map< std::type_index, int > &countPerLeafType, const std::string &prefix) const override
 We need to tag leaves and tell unique leaves that they are responsible to define the uniforms and set the shader arguments.
void getUniformDefinitionList (std::string &definitionList, const std::vector< int > &indices, const std::string &prefix) const override
 Collect uniform/sampler definitions.
void getVariableDefinitionList (std::string &definitionList, const std::vector< int > &indices, const std::string &prefix) const override
 Collect variable definitions.
int setArguments (GL::Program &p, const std::vector< int > &indicesIn, const std::string &prefix) const override
 Set uniform/sampler arguments.
std::string evalString (bool tagAndAssign=true) const override
 Implementation of GlExprInterface interface.
Public Member Functions inherited from ImFusion::ImageMath::internal::GlExprInterface
ExprInterfaceexprInterface ()
 Get image descriptor of the wrapped expression.
const ExprInterfaceexprInterface () const
virtual bool setMagFilter (ImageMath::MagFilter mag)
 Set interpolation behaviour of the current leaf (only).
virtual bool setWrap (ImageMath::Wrap wrap)
 Set interpolation behaviour of the current leaf (only).
bool setMagFilterRecursive (ImageMath::MagFilter mag)
 Set interpolation behaviour of the current leaf and all of its children.
bool setWrapRecursive (ImageMath::Wrap wrap)
 Set wrap behaviour of the current leaf and all of its children.

Static Public Attributes

static constexpr bool has_variable = OperandT::has_variable

Protected Attributes

int m_numChannels
std::shared_ptr< Maskm_mask
std::shared_ptr< GL::MultiAbstractInclude< GlMask > > m_multiInclude
internal::StashTpl< OperandT, StashVariable< double > > m_stashedOperand
Protected Attributes inherited from ImFusion::ImageMath::internal::MaskLeafGl
std::string m_name = "uninitialized"
bool m_tagged = false
std::shared_ptr< GL::MultiAbstractInclude< GlMask > > m_multiInclude

Member Function Documentation

◆ numImgs()

template<typename OperandT>
int ImFusion::ImageMath::MaskLeaf< OperandT >::numImgs ( ) const
inlineoverridevirtual

Return number of images of this expression.

Implements ImFusion::ImageMath::ExprInterface.

◆ deviceStrategy()

template<typename OperandT>
DeviceStrategy ImFusion::ImageMath::MaskLeaf< OperandT >::deviceStrategy ( ) const
inlineoverridevirtual

Return DeviceStrategy of this expression.

Implements ImFusion::ImageMath::ExprInterface.

◆ imgDesc()

template<typename OperandT>
ImageDescriptor ImFusion::ImageMath::MaskLeaf< OperandT >::imgDesc ( ) const
inlineoverridevirtual

Return ImageDescriptor of this expression. This reference is expected to remain the same while the class exists.

Implements ImFusion::ImageMath::ExprInterface.

◆ children() [1/2]

template<typename OperandT>
std::vector< internal::GlExprInterface * > ImFusion::ImageMath::MaskLeaf< OperandT >::children ( )
inlineoverridevirtual

Used for traversing the expression tree. Contains the immediate children of node.

Implements ImFusion::ImageMath::internal::GlExprInterface.

◆ children() [2/2]

template<typename OperandT>
std::vector< const internal::GlExprInterface * > ImFusion::ImageMath::MaskLeaf< OperandT >::children ( ) const
inlineoverridevirtual

Used for traversing the expression tree. Contains the immediate children of node.

Implements ImFusion::ImageMath::internal::GlExprInterface.

◆ mask()

template<typename OperandT>
const std::shared_ptr< Mask > & ImFusion::ImageMath::MaskLeaf< OperandT >::mask ( ) const
inlineoverridevirtual

◆ operand() [1/2]

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

◆ operand() [2/2]

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

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