![]() |
ImFusion SDK 4.3
|
#include <ImFusion/ImageMath/Tpl/Variable.h>
Specialization of ExprBaseTpl for a variable, e.g. More...
Inheritance diagram for Variable:Specialization of ExprBaseTpl for a variable, e.g.
a result of another computation which is not yet available during creation of the expr. Only one per expression is allowed at current.
Each expression may contain one Variable. This is a placeholder variable which can be used to use intermediate results directly within your expression or e.g. to use the result of a computation within your shader directly within your expression. In order to substitute such a variable on the CPU you can use VariableSubstitutionOp operator while on the GPU there is a specific argument you can pass. This feature can also be used in combination with the polymorphic interface. Meaning you can have different code paths for you CPU/GPU execution and still patch in different expressions.
The most common use case would be like this: Assume you have some computation based on a target and a source image. Now let us further assume that you want to flexibly apply an expression to either of those two images for whatever reason. One example would be DRR generation where you want to apply an exponential function if you want to display attenuation images.
Example:
The big advantage of this approach is that the code in the compute() function and the involved shader are completely independent from the actual expression.
Public Types | |
| using | expr_type = void |
| using | var_type = void |
| using | imf_img_type = void |
Public Member Functions | |
| Variable (int channels) | |
| template<typename ImgT> | |
| auto | convertToMemImgExpr () const noexcept |
| auto | convertToSharedImgExpr (std::size_t) const |
| template<typename SubOperandT> | |
| auto | substituteVariable (const SubOperandT &operand) const |
| Substitutes any Variable leaf. | |
| ImageDescriptor | imgDesc () const override |
| Return ImageDescriptor of this expression. This reference is expected to remain the same while the class exists. | |
| int | numImgs () const override |
| Return number of images of this expression. | |
| DeviceStrategy | deviceStrategy () const override |
| Return DeviceStrategy of this expression. | |
Public Member Functions inherited from ExprBaseTpl< Variable > | |
| const auto & | get () const |
| get a const reference to this with the actual type | |
| auto & | get () |
| get a 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 | binaryOp (RhsT rhs, const Op &func=Op(), typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| auto | binaryOp (Eigen::Matrix< RhsT, Dim, 1, Options, MaxRows, MaxCols > rhs, const Op &func=Op(), typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| auto | binaryOp (const ExprBaseTpl< RhsT > &rhs, const Op &func, const StringOp &stringFunc) const |
| auto | binaryOp (RhsT rhs, const Op &func, const StringOp &stringFunc, typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| auto | binaryOp (Eigen::Matrix< RhsT, Dim, 1, Options, MaxRows, MaxCols > rhs, const Op &func, const StringOp &stringFunc, typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| auto | unaryOp (const Op &func=Op()) const |
| auto | unaryOp (const Op &func, const StringOp &stringFunc) 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}) | |
| ADD_SPECIAL_SWIZZLE (y, {1}) | |
| ADD_SPECIAL_SWIZZLE (z, {2}) | |
| ADD_SPECIAL_SWIZZLE (w, {3}) | |
| ADD_SPECIAL_SWIZZLE (r, {0}) | |
| ADD_SPECIAL_SWIZZLE (g, {1}) | |
| ADD_SPECIAL_SWIZZLE (b, {2}) | |
| ADD_SPECIAL_SWIZZLE (a, {3}) | |
| ADD_SPECIAL_SWIZZLE (xy, std::vector< size_t >({0, 1})) | |
| ADD_SPECIAL_SWIZZLE (rg, std::vector< size_t >({0, 1})) | |
| ADD_SPECIAL_SWIZZLE (xyz, std::vector< size_t >({0, 1, 2})) | |
| ADD_SPECIAL_SWIZZLE (xyzw, std::vector< size_t >({0, 1, 2, 3})) | |
| ADD_SPECIAL_SWIZZLE (rgb, std::vector< size_t >({0, 1, 2})) | |
| ADD_SPECIAL_SWIZZLE (rgba, std::vector< size_t >({0, 1, 2, 3})) | |
| 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) | |
| ADD_CHANNEL_REDUCTION_OPERATOR (channelProd, mult) | |
| ADD_CHANNEL_REDUCTION_OPERATOR (channelMax, max) | |
| ADD_CHANNEL_REDUCTION_OPERATOR (channelMin, min) | |
| ADD_CHANNEL_REDUCTION_OPERATOR (length, length) | |
| auto | channelMean () |
| auto | squaredLength () const |
| auto | channelDistance (const ExprBaseTpl< RhsT > &other) const |
| auto | channelDistance (const Eigen::Matrix< T, Dim, 1 > c) |
| 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. | |
| auto | select (LhsT lhs, RhsT rhs, typename std::enable_if< std::is_arithmetic_v< LhsT > &&std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| Ternary (condition.x ? if_true : if_false) operator. | |
| auto | select (LhsT lhs, const ExprBaseTpl< RhsT > &rhs, typename std::enable_if< std::is_arithmetic_v< LhsT > >::type *=nullptr) const |
| Ternary (condition.x ? if_true : if_false) operator. | |
| auto | select (const ExprBaseTpl< LhsT > &lhs, RhsT rhs, typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const |
| Ternary (condition.x ? if_true : if_false) operator. | |
| ADD_REDUCTION_OPERATOR (sum, add) | |
| ADD_REDUCTION_OPERATOR (prod, mult) | |
| ADD_ARG_REDUCTION_OPERATOR (min, min) | |
| ADD_ARG_REDUCTION_OPERATOR (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 |
| 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 |
| auto | resample (SharedImage &inputDesc, SharedImage &outputDesc, std::enable_if_t< std::is_same_v< T, SharedImage > > *=nullptr) const |
| auto | resample (SharedImageSet &inputDesc, SharedImageSet &outputDesc, std::enable_if_t< std::is_same_v< T, SharedImageSet > > *=nullptr) const |
Public Member Functions inherited from VariableGl | |
| std::string | evalString (bool) const override |
| Print expression. | |
| void | tagAndAssignNames (std::unordered_map< TaggingIndex, const void * > &, std::unordered_map< std::type_index, int > &, const std::string &) 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 &, const std::vector< int > &, const std::string &) const override |
| Collect uniform/sampler definitions. | |
| void | getVariableDefinitionList (std::string &, const std::vector< int > &, const std::string &) const override |
| Collect variable definitions. | |
| int | setArguments (GL::Program &, const std::vector< int > &, const std::string &) const override |
| Set uniform/sampler arguments. | |
| 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. | |
Public Member Functions inherited from GlExprInterface | |
| ExprInterface & | exprInterface () |
| Get image descriptor of the wrapped expression. | |
| const ExprInterface & | exprInterface () 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 = true |
|
inlineoverridevirtual |
Return ImageDescriptor of this expression. This reference is expected to remain the same while the class exists.
Implements ExprInterface.
|
inlineoverridevirtual |
Return number of images of this expression.
Implements ExprInterface.
|
inlineoverridevirtual |
Return DeviceStrategy of this expression.
Implements ExprInterface.