ImFusion SDK 4.3
ImFusion::ImageMath Namespace Reference

Arithmetic operations on images and arrays. More...

Detailed Description

Arithmetic operations on images and arrays.

See also
ImFusionImageMath

Classes

class  Array
 Specialization of ExprBase for a image leaf, i.e. More...
 
class  ChannelWiseScalar
 Specialization of ExprBaseTpl for a channel wise scalar value. More...
 
class  Coordinates
 ImageMath leaf for using world coordinates in ImageMath expressions. More...
 
class  DeformationLeaf
 Leaf node for ImageMath expressions that represents a deformation (cf Deformation). More...
 
class  ExprBase
 Base class for expressions (non-templated) (needs to be empty in order to enable empty base class optimization!) More...
 
class  ExprBaseTpl
 Base class for compile-time optimized expressions (curiously recurring template pattern (CRTP)) More...
 
class  ExprInterface
 ImageMath base class to provide an interface for non-CRTP polymorphism. More...
 
class  GlExpr
 Wrapper for using a ExprBase as GlAbstractInclude. More...
 
class  MaskLeaf
 Use a Mask/GlMask as an ImageMath leaf that can be used in ImageMath expressions. More...
 
class  Noise
 ImageMath leaf for generating noise in ImageMath expressions. More...
 
class  OperandDeformation
 Use an ImageMath expression as a Deformation. More...
 
class  OperandMask
 Mask/GlMask from an ImageMath expression. More...
 
class  OperandMaskBase
 
class  Scalar
 Specialization of ExprBaseTpl for a single scalar value. More...
 
class  StashVariable
 Helper Variable class for use with stashes. More...
 
class  StringLeaf
 Specialization of ExprBaseTpl for a simple leaf representing a string. More...
 
class  Variable
 Specialization of ExprBaseTpl for a variable, e.g. More...
 

Typedefs

using reduction_type = typename Eigen::Matrix<double, Eigen::Dynamic, 1>
 Reduction result type.
 
using reduction_per_image_type = typename Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
 Reduction result type for multiple images images.
 
using arg_per_image_type = typename Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>
 Reduction argument type for argMin/-Max.
 

Enumerations

enum class  NoiseType { Gaussian = 0 , Uniform = 1 , Shot = 2 }
 enum for defining which noise type to generate
 
enum class  ExpressionSplittingCase { NO_OUTPUT_IN_EXPR , EXPRESSION_DISTRIBUTES , SEPARATE_BUFFER }
 In a number of applications, particularly as they arise from CT reconstruction, a user may compute out = outExpr(shaderOutput). More...
 
enum class  DeviceStrategy { ForceCPU = 0 , ForceGPU , Auto }
 Computing device strategy. More...
 
enum class  Wrap { ClampToEdge = 0x812F , ClampToBorder = 0x812D }
 Describes the wrapping mode applied. More...
 
enum class  MagFilter { Nearest = 0x2600 , Linear = 0x2601 }
 Describes the magnification filter applied. More...
 
enum class  CoordinateType { World = 0 , Image = 1 , Texture = 2 , Pixel = 3 }
 enum for defining which coordinate system to use
 

Functions

template<typename T>
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 deduction from constructor arguments)
 
template<typename T>
auto makeArray (SharedImage &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 deduction from constructor arguments)
 
template<typename T>
auto makeArray (SharedImageSet &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 deduction from constructor arguments)
 
template<typename T>
auto makeArray (const 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 deduction from constructor arguments)
 
template<typename T>
auto makeArray (const SharedImage &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 deduction from constructor arguments)
 
template<typename T>
auto makeArray (const SharedImageSet &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 deduction from constructor arguments)
 
template<typename T, int Dim>
ChannelWiseScalar< T, Dim > makeChannelWiseScalar (Eigen::Matrix< T, Dim, 1 > val)
 Convenience function to create a channel wise scalar leaf (needed as until c++17 there is no template type deduction from constructor arguments)
 
template<typename... Ts>
auto combineChannels (Ts &... args)
 
template<typename... Ts>
const auto combineChannels (const Ts &... args)
 
template<typename T>
Coordinates< const TypedImage< T > > makeCoordinates (const TypedImage< T > &img, CoordinateType coordType=CoordinateType::World)
 This function creates a suitable Coordinates object.
 
IMFUSION_EXPORT_NO_SDK Coordinates< const SharedImagemakeCoordinates (const SharedImage &img, CoordinateType coordType=CoordinateType::World)
 
IMFUSION_EXPORT_NO_SDK Coordinates< const SharedImageSetmakeCoordinates (const SharedImageSet &img, CoordinateType coordType=CoordinateType::World)
 
template<class T>
Coordinates< const T > makeCoordinates (const T &img, vec4 normal, CoordinateType coordType=CoordinateType::World)
 C++ only allows templated constructors in C++17.
 
template<typename OperandT>
auto makeMaskLeaf (const OperandT &operand, std::shared_ptr< Mask > mask)
 
template<typename T>
Noise< const TypedImage< T > > makeNoise (const TypedImage< T > &img, NoiseType noiseType=NoiseType::Gaussian, float alpha=0.0, float beta=1.0, int seed=0)
 This function creates a suitable Noise object.
 
IMFUSION_EXPORT_NO_SDK Noise< const SharedImage, Scalar< float >, Scalar< float > > makeNoise (const SharedImage &img, NoiseType noiseType=NoiseType::Gaussian, float alpha=0.0, float beta=1.0, int seed=0)
 
IMFUSION_EXPORT_NO_SDK Noise< const SharedImageSetmakeNoise (const SharedImageSet &img, NoiseType noiseType=NoiseType::Gaussian, float alpha=0.0, float beta=1.0, int seed=0)
 
std::string IMFUSION_EXPORT_NO_SDK getNoiseTypeName (NoiseType noiseType)
 
template<typename T>
Scalar< typename std::decay_t< T > > makeScalar (T &&val)
 Convenience function to create a scalar leaf (needed as until c++17 there is no template type deduction from constructor arguments)
 
template<typename T>
Scalar< typename std::decay_t< T > & > makeScalarWrapper (T &val)
 Convenience function to create a scalar leaf wrapping a scalar variable (needed as until c++17 there is no template type deduction from constructor arguments)
 
template<typename Op>
ExpressionSplittingCase classifyExpression (const ExprBase &expr, int shaderOutputChannels, const SharedImageSet &outputImage)
 Helper function to classify whether an additional output buffer is required to evaluate the expression expr.
 

Enumeration Type Documentation

◆ ExpressionSplittingCase

enum class ExpressionSplittingCase
strong

In a number of applications, particularly as they arise from CT reconstruction, a user may compute out = outExpr(shaderOutput).

Here outExpr is an ImageMath expression, out is an image, and shaderOutput is the output of a previous computation. This previous computation is assumed to proceed in steps taking the form shaderOutput = shaderOutput1 + shaderOutput2 +... + shaderOutputN We can classify the treatment of this computation into three cases:

Case I - no output) If outExpr does not itself contain out, a user can accumulate the individual shader-outputs shaderOutput1, shaderOutput2, ... , shaderOutputN using out temporarily as an accumulation buffer. As a last-step, applying outExpr to out in-place yields the correct final result.

Case II - expression distributes) If outExpr does itself contain out, this strategy is in general no-longer viable except for in very special cases. To be more precise, we write outExpr(out, var) to refer to the output-expression with input var (we substituted shaderOutput for this above). In order to simplify the notation, we replace outExpr by the symbol ~, i.e. we write outExpr(out,var) := out ~ var. If out = out ~ (shaderOutput1 + shaderOutput2 + ... + shaderOutputN), we can only use out as an accumulation buffer if ~ distributes suitably over shaderOutput1 + ... + shaderOutputN. What we mean by this is that, on each pixel and each channel, out ~ (shaderOutput 1 + ... + shaderOutputN) = ( ((out ~ shaderOutput1) ~ shaderOutput2) ~ ... ~ shaderOutput N) An important case where this holds is the case that a ~ b = a + alpha*b, where alpha is some real number. The number alpha may vary with the pixel and the channel. (Technically, another case arising from the exponential map as a group homomorphism from (R,+) to (R_+, *) is given by a ~ b = a * exp(alpha*b). We will ignore this case for the time being and treat it like Case III).

Case III - separate buffer) A separate buffer is used for the accumulation of shaderOutput1 + ... + shaderOutputN. In a final step exprOut(out, shaderOutput1 + ... + shaderOutputN) is evaluated into out

The above deals with the case shaderOutput = shaderOutput1 + ... + shaderOutputN. We can similarly consider the case shaderOutput = max(shaderOutput1, ..., shaderOutputN), in which case a ~ b = max(a, alpha + b) is the special case relevant for Case II. Technically, we could generalize alpha + b to any monotone function of b, but we will refrain from doing so for the sake of simplicity.

◆ DeviceStrategy

enum class DeviceStrategy
strong

Computing device strategy.

The entries are ordered such that in doubt, the smaller one is chosen

◆ Wrap

enum class Wrap
strong

Describes the wrapping mode applied.

See also
GL::Sampler
Enumerator
ClampToEdge 

Tex coordinates are clamped to [0, 1] range.

ClampToBorder 

Tex coordinates are clamped to [0, 1], edge pixels use constant border color.

◆ MagFilter

enum class MagFilter
strong

Describes the magnification filter applied.

See also
GL::Sampler
Note
Only supported on the GPU. On the CPU we will always use Nearest
Enumerator
Nearest 

Select nearest texel.

Linear 

Use linear filtering.

Function Documentation

◆ makeCoordinates()

template<class T>
Coordinates< const T > makeCoordinates ( const T & img,
vec4 normal,
CoordinateType coordType = CoordinateType::World )

C++ only allows templated constructors in C++17.

See also
Coordinates::Coordinates

◆ classifyExpression()

template<typename Op>
ExpressionSplittingCase classifyExpression ( const ExprBase & expr,
int shaderOutputChannels,
const SharedImageSet & outputImage )

Helper function to classify whether an additional output buffer is required to evaluate the expression expr.

See also
the description in the ExpressionCase enum. The template argument Op is ImgOps::add for the case that that shaderOutput = shaderOutput1 + ... + shaderOutputN and ImgOps::max for the case that shaderOutput = max(shaderOutput1, ... , shaderOutputN) and likewise for min. If expr is equial to nullptr, this is interpreted as exprOut(shaderOutput) = shaderOutput.
Parameters
shaderOutputChannels- how many channels shaderOutput has. Even if the output-expression does not contain outputImage, we can only use outputImage for temporary storage if it has the correct number of channels.
Search Tab / S to search, Esc to close