![]() |
ImFusion SDK 4.3
|
#include <ImFusion/ImageMath/Poly/ExprBase.h>
Base class for expressions (non-templated) (needs to be empty in order to enable empty base class optimization!) More...
Inheritance diagram for ExprBase:Base class for expressions (non-templated) (needs to be empty in order to enable empty base class optimization!)
ExprBase provides a (non-templated) base class for arithmetic operations on ImFusion images. This class can be used in interfaces and provides an interface in order to evaluate a arithmetic expression into a SharedImage or a SharedImageSet. If the expression is fully known at compile-time using the ExprBaseTpl is encouraged! This subclass provides a compile time optimization of expressions using the curiously recurring template pattern (CRTP).
Example usage for polymorphic expressions:
Public Types | |
| enum class | ExprType { Scalar = 0 , SharedImage = 1 , SharedImageSet = 2 , Variable = 3 } |
Public Member Functions | |
| virtual std::unique_ptr< ExprBase > | clone () const =0 |
| Clone the current expression. May not return nullptr. | |
| virtual std::unique_ptr< ExprBase > | convertToSharedImgExpr (std::size_t index) const =0 |
| Convert a SharedImageSet expression to a SharedImage expression. | |
| ImageDescriptor | imgDesc () const |
| Return ImageDescriptor of the expression (forwards to the ExprInterface) | |
| int | numImgs () const |
| Return the number of images of the expression (forwards to the ExprInterface) | |
| virtual ExprType | exprType () const =0 |
| Return the ImFusion image type, i.e. NoImage, SharedImage, SharedImageSet. | |
| template<typename T, typename ImgType = void> | |
| auto | evaluateIntoImage (bool clearShiftScale=false) const |
| Evaluate expression into an image. | |
Variable substitution | |
| virtual std::unique_ptr< ExprBase > | substituteVariableWithImg (const SharedImage &variable) const =0 |
| virtual std::unique_ptr< ExprBase > | substituteVariableWithImg (const SharedImageSet &variable) const =0 |
Substitute all variables with variable. | |
Evaluate an expression into an Array (polymorphic version) | |
| void | eval (Array< SharedImage, void > &img, const SharedImage *variable) const |
| void | eval (Array< SharedImage, void > &img) const |
| Evaluate into SharedImage. | |
| void | eval (Array< SharedImageSet, void > &img, const SharedImageSet *variable) const |
Evaluate into SharedImageSet. Variable leafs will be substituted with variable. | |
| void | eval (Array< SharedImageSet, void > &img) const |
| Evaluate into SharedImageSet. | |
Convert to GlExprInterface | |
| internal::GlExprInterface & | glExprInterface () |
| const internal::GlExprInterface & | glExprInterface () const |
Convert to ExprInterface | |
| ExprInterface & | exprInterface () |
| const ExprInterface & | exprInterface () const |
Special functions | |
| template<typename Op> | |
| reduction_type | reduce (std::vector< vec4i > *arg=nullptr) const |
| std::unique_ptr< ExprBase > | forceCPU () const |
| Forces CPU execution. | |
| std::unique_ptr< ExprBase > | forceGPU () const |
| Forces GPU execution. | |
Channel swizzling | |
| std::unique_ptr< ExprBase > | channelSwizzle (const std::vector< std::size_t > &indices) const |
Predefined unary operators | |
| template<typename CastT> | |
| std::unique_ptr< ExprBase > | cast () const |
Predefined reduction operators | |
| ADD_REDUCTION_OP_DEF (sum, add) | |
| ADD_REDUCTION_OP_DEF (prod, mult) | |
| ADD_ARG_REDUCTION_OP_DEF (min, min) | |
| ADD_ARG_REDUCTION_OP_DEF (max, max) | |
| 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 |
Implementation for eval() | |
| virtual void | evalImpl (Array< SharedImage, void > &img) const =0 |
| virtual void | evalImpl (Array< SharedImageSet, void > &img) const =0 |
| Implementation functionality used in eval() | |
|
pure virtual |
Clone the current expression. May not return nullptr.
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
|
pure virtual |
Substitute all variables with variable
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
|
pure virtual |
Substitute all variables with variable.
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
| void eval | ( | Array< SharedImage, void > & | img, |
| const SharedImage * | variable ) const |
Evaluate into SharedImage. Variable leafs will be substituted with variable.
|
pure virtual |
Convert a SharedImageSet expression to a SharedImage expression.
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
|
pure virtual |
Return the ImFusion image type, i.e. NoImage, SharedImage, SharedImageSet.
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
|
inline |
*this using the operator Op | std::unique_ptr< ExprBase > channelSwizzle | ( | const std::vector< std::size_t > & | indices | ) | const |
*this according to indices, i.e. the channel 0 gets mapped to the channel indices[0]. | Eigen::Matrix< double, Eigen::Dynamic, 1 > mean | ( | ) | const |
*this | Eigen::Matrix< double, Eigen::Dynamic, 1 > l1Norm | ( | ) | const |
*this | Eigen::Matrix< double, Eigen::Dynamic, 1 > squaredl2Norm | ( | ) | const |
*this | Eigen::Matrix< double, Eigen::Dynamic, 1 > l2Norm | ( | ) | const |
*this | Eigen::Matrix< double, Eigen::Dynamic, 1 > lpNorm | ( | double | p | ) | const |
*this | Eigen::Matrix< double, Eigen::Dynamic, 1 > lInfNorm | ( | ) | const |
*this
|
protectedpure virtual |
Implementation functionality used in eval()
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.
|
protectedpure virtual |
Implementation functionality used in eval()
Implemented in BinaryOp< Op >, CastWrapper< CastT >, ChannelSwizzleView, DeviceStrategyWrapper, PolyWrapper< ExprT >, and UnaryOp< Op >.