ImFusion C++ SDK 4.4.0
ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT > Class Template Reference

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

ImageMath leaf for generating noise in ImageMath expressions. More...

Inheritance diagram for ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT >:

Detailed Description

template<typename imf_img_typeT, typename AlphaT = Scalar<float>, typename BetaT = Scalar<float>>
class ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT >

ImageMath leaf for generating noise in ImageMath expressions.

As C++ does not deduce constructor template arguments until C++17, the makeNoise convenience functions are also included in this file. Different types of noise are implemented and the meaning of the parameters alpha and beta depends on the type of noise Gaussian: random normal distribution with mean = alpha and variance = beta Uniform: random uniform distribution on [alpha, beta] Shot: Shot noise approximated using a Normal distribution. The value at each pixel is alpha + beta*sqrt(alpha)*randn(). Alpha is the original value of the image and the expected value, beta quantifies the amount of noise. This type of noise preserves zeros.

Public Types

using expr_type = float
 The expr_type value gives the result of each component of this expression.
using var_type = void
using imf_img_type = imf_img_typeT

Public Member Functions

 Noise (std::vector< ImageDescriptor > descriptors, NoiseType noiseType, const AlphaT &alpha, const BetaT &beta, int seed=0)
 Create a Noise constructor using vector of ImageDescriptor objects.
ImageDescriptor imgDesc () const override
 Return ImageDescriptor of this expression. This reference is expected to remain the same while the class exists.
template<typename ImgT>
auto convertToMemImgExpr () const noexcept
auto convertToSharedImgExpr (std::size_t index) const
IMFUSION_STRONG_INLINE expr_type eval (const std::size_t i, const vec4i &coord) const
 CPU implementation.
int numImgs () const override
 Return number of images of this expression.
ImageMath::DeviceStrategy deviceStrategy () const override
 Return DeviceStrategy of this expression.
Public Member Functions inherited from ImFusion::ImageMath::ExprBaseTpl< ImplType >
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
template<typename Op, typename RhsT>
auto binaryOp (const ExprBaseTpl< RhsT > &rhs, const Op &func=Op()) const
template<typename Op, typename RhsT>
auto binaryOp (RhsT rhs, const Op &func=Op(), typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const
template<typename Op, typename RhsT, int Dim, int Options, int MaxRows, int MaxCols>
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
template<typename Op, typename StringOp, typename RhsT>
auto binaryOp (const ExprBaseTpl< RhsT > &rhs, const Op &func, const StringOp &stringFunc) const
template<typename Op, typename StringOp, typename RhsT>
auto binaryOp (RhsT rhs, const Op &func, const StringOp &stringFunc, typename std::enable_if< std::is_arithmetic_v< RhsT > >::type *=nullptr) const
template<typename Op, typename StringOp, typename RhsT, int Dim, int Options, int MaxRows, int MaxCols>
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
template<typename Op>
auto unaryOp (const Op &func=Op()) const
template<typename Op, typename StringOp>
auto unaryOp (const Op &func, const StringOp &stringFunc) const
template<typename Op>
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
template<size_t i>
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
template<typename T>
auto substituteVariableWithImg (T &img) const
auto operator- () const
template<typename CastT>
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,.
template<typename Op>
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
template<typename RhsT>
auto channelDistance (const ExprBaseTpl< RhsT > &other) const
template<typename T, int Dim>
auto channelDistance (const Eigen::Matrix< T, Dim, 1 > c)
template<typename RhsT>
auto dot (const ExprBaseTpl< RhsT > &other) const
template<typename VariableT>
auto stashThenApply (const ExprBaseTpl< VariableT > &varExpr) const
template<typename VarT = double>
auto hnormalized () const
template<typename VarT = double>
auto normalized () const
auto homogeneous () const
auto appendZero () const
template<typename LhsT, typename RhsT>
auto select (const ExprBaseTpl< LhsT > &lhs, const ExprBaseTpl< RhsT > &rhs) const
 Ternary (condition.x ? if_true : if_false) operator.
template<typename LhsT, typename RhsT>
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.
template<typename LhsT, typename RhsT>
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.
template<typename LhsT, typename RhsT>
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
template<typename ImgType = void>
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
template<bool includeDeformation = false>
auto resample (const ImageDescriptorWorld &inputDesc, const ImageDescriptorWorld &outputDesc) const
template<bool includeDeformation = false, typename T = SharedImage>
auto resample (SharedImage &inputDesc, SharedImage &outputDesc, std::enable_if_t< std::is_same_v< T, SharedImage > > *=nullptr) const
template<bool includeDeformation = false, typename T = SharedImageSet>
auto resample (SharedImageSet &inputDesc, SharedImageSet &outputDesc, std::enable_if_t< std::is_same_v< T, SharedImageSet > > *=nullptr) const
Public Member Functions inherited from ImFusion::ImageMath::internal::NoiseGl< ImplType >
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.
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 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 = false

Protected Attributes

AlphaT m_alpha
BetaT m_beta
Protected Attributes inherited from ImFusion::ImageMath::internal::NoiseGlBase
std::string m_name = "uninitialized"
bool m_tagged = false

Additional Inherited Members

Protected Member Functions inherited from ImFusion::ImageMath::internal::NoiseGlBase
void tagAndAssignNamesImpl (std::unordered_map< ImageMath::internal::TaggingIndex, const void * > &taggedLeaves, std::unordered_map< std::type_index, int > &countPerLeafType, const std::string &prefix, internal::uintptr_t imgDescPtr) const
void getUniformDefinitionListImpl (std::string &definitionList, const std::vector< int > &indices, const std::string &prefix) const
void getVariableDefinitionListImpl (std::string &definitionList, const std::vector< int > &indices, const std::string &prefix, NoiseType noiseType) const
int setArgumentsImpl (GL::Program &p, const std::string &prefix, const vec3f &dimensions, const vec3i &stride, uint32_t seedHash) const
std::string evalStringImpl (bool tagAndAssign, const std::string &alphaString, const std::string &betaString, int numChannels, NoiseType noiseType) const

Member Function Documentation

◆ imgDesc()

template<typename imf_img_typeT, typename AlphaT = Scalar<float>, typename BetaT = Scalar<float>>
ImageDescriptor ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT >::imgDesc ( ) const
inlineoverridevirtual

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

Implements ImFusion::ImageMath::ExprInterface.

◆ numImgs()

template<typename imf_img_typeT, typename AlphaT = Scalar<float>, typename BetaT = Scalar<float>>
int ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT >::numImgs ( ) const
inlineoverridevirtual

Return number of images of this expression.

Implements ImFusion::ImageMath::ExprInterface.

◆ deviceStrategy()

template<typename imf_img_typeT, typename AlphaT = Scalar<float>, typename BetaT = Scalar<float>>
ImageMath::DeviceStrategy ImFusion::ImageMath::Noise< imf_img_typeT, AlphaT, BetaT >::deviceStrategy ( ) const
inlineoverridevirtual

Return DeviceStrategy of this expression.

Implements ImFusion::ImageMath::ExprInterface.


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