ImFusion C++ SDK 4.4.0
ImFusion::GlTPSDeformation Class Reference

#include <ImFusion/GL/GlTPSDeformation.h>

The GlTPSDeformation class provides deformations using a thin-plate splines (TPS). More...

Inheritance diagram for ImFusion::GlTPSDeformation:

Detailed Description

The GlTPSDeformation class provides deformations using a thin-plate splines (TPS).

Public Member Functions

 GlTPSDeformation (int dimension)
 GlTPSDeformation (SharedImage *img)
 GlTPSDeformation (const GlTPSDeformation &other)
Deformationclone () const override
 Returns a copy of the deformation.
int dimension () const override
 Dimension of the deformation.
void setUseLocalModel (bool useLocal)
bool useLocalModel () const
void setPointCorrespondences (const std::vector< vec3 > &pts1, const std::vector< vec3 > &pts2)
 Set point correspondences.
void setDefaultControlPoints (SharedImage *img, bool fit=false)
 Set the four (in 2D) or eight (in 3D) default control points in the image corners, optionally fitting it to the content.
void setControlPoints (const std::vector< vec3 > &pts)
 Set the control points given in world coordinate system.
std::vector< vec3 > controlPoints () const override
 Get current control points.
void addControlPoint (const vec3 &points)
 Add control point.
void removeControlPoint (int index)
 Remove control point at index.
vec3 displacement (const vec3 &pos) const override
 Get displacement at given point.
int setIncludeArguments (GL::Program &p, const SharedImage *img=nullptr, const std::string &prefix="deform") const override
 Initializes the FFDeformation shader header to deform the given image.
void setRegularizerWeight (double value)
double regularizerWeight () const
void setDisplacement (const std::vector< vec3f > &d) override
 Set displacement in world coordinate units for every control points.
void setDisplacement (int idx, const vec3f &d)
 Sets the displacement in world coordinate units at the given control point.
std::vector< vec3f > displacements () const override
 Get displacement in world coordinate units of all control points.
const GlImagedisplacementTexture () const
const GlImagecontrolPointTexture () const
int numberOfControlPoints () const override
 Returns the number of control points.
bool isIdentity () const override
 Returns if the current state of the deformation transformations the image or not.
void setIdentity () override
 Sets the displacement of all control points to zero.
void configure (const Properties *p) override
 Set one or multiple properties.
void configuration (Properties *p) const override
 Retrieve the properties of this object.
std::string id () const override
 Returns a unique string identifier for this type of deformation.
Public Member Functions inherited from ImFusion::ParametricDeformation
 ParametricDeformation (const std::string &shaderPath)
 Initializes the parametric deformation with path to the GlInclude file.
 ~ParametricDeformation () override
 Destructor.
virtual void setParameters (const std::vector< double > &pars)
 Set the parameters of the deformation.
virtual void parameters (std::vector< double > &parsOut) const
 Retrieve the current parameters of the deformation.
virtual int numberOfParameters () const
 Returns the number of parameters e.g. for optimization.
Public Member Functions inherited from ImFusion::Deformation
 Deformation (const std::string &shaderPath)
 Initializes the Deformation with path to the GlInclude file.
virtual vec3 displacement (const vec2 &pos) const
 Returns the displacement at the world position pos.
virtual vec3 displacePoint (const vec3 &point) const
 Returns the displaced position of the given point in world-coordinates.
void setDisabled (bool flag)
 Set a disabled flag in order to hide the visualization of this deformation.
bool disabled () const
 Return whether the deformation was set to disabled.
virtual std::unique_ptr< SharedImageSetsupportingImages () const
 Returns the images that, together with the configuration, defines the deformation.
Public Member Functions inherited from ImFusion::GL::AbstractInclude
 AbstractInclude (const std::string &defineName, const std::string &includePath)
 Creates a AbstractInclude for the given define and with the corresponding GLSL file at includePath.
const std::stringdefineName () const
 Returns the name of define used by this include.
const std::stringincludePath () const
 Returns the path to the included shader file.
virtual std::function< std::string(const std::string &)> includeCodeSubstitution () const
 Optionally the abstract include can provide a function to change the shader code.
virtual std::vector< AbstractInclude * > dependentIncludes () const
 Returns a list of dependent abstract includes that need to be included as well.
virtual Fingerprint fingerprint () const
 Provides a finger print of the include.
Public Member Functions inherited from ImFusion::GL::MultiIncludable< Deformation, const SharedImage * >
std::shared_ptr< MultiIncludeTypecreateMultiInclude (const std::string &replacementToken)
 Instantiates a new AbstractInclude instance where all occurrences of baseToken provided during construction are replaces with replacementToken according to the specified replacementScheme.
virtual int setIncludeArguments (Program &prog, IncludeArgumentsTypes... includeArgs, const std::string &token) const=0
 Interface that multi includes should use to configure the shader include (such as setting uniforms, binding textures, etc).
Public Member Functions inherited from ImFusion::Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Protected Attributes

std::vector< vec3 > m_pts
 Control points.
std::vector< vec3f > m_disp
 Displacement of control points in mm.
GlImagem_texDisp
 Displacement texture (same content as m_disp).
Eigen::MatrixXd m_W
GlImagem_texParameters
GlImagem_texControlPoints
int m_dimension
double m_lambda
bool m_useLocal
Protected Attributes inherited from ImFusion::Deformation
bool m_disabled
 Disabled flag for visualization.
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Additional Inherited Members

Public Types inherited from ImFusion::GL::MultiIncludable< Deformation, const SharedImage * >
using MultiIncludeType
 Alias for type of a multi-include instance of the original include.
Static Public Member Functions inherited from ImFusion::Deformation
static std::string defineName ()
 Returns the define name of GlAbstractInclude for all deformations.
static std::string defineSuffix ()
 Returns "DEFORM".
static std::string multiIncludeDefine (const std::string &replacementToken)
 Returns "IMAGE_" + toUpper(replacementToken).
Public Attributes inherited from ImFusion::Deformation
Signal< const DeformationEvent & > signalChanged
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
Protected Member Functions inherited from ImFusion::Deformation
void notifyListeners (const DeformationEvent &event) const
 convenience function to call signalChanged.emitSignal(event).
Protected Member Functions inherited from ImFusion::GL::MultiIncludable< Deformation, const SharedImage * >
 MultiIncludable (Deformation *crtpInstance, const std::string &baseToken, Flags< ShaderTextReplacement > replacementScheme)
 Instantiate and configure the MultiIncludable interface.

Member Function Documentation

◆ clone()

Deformation * ImFusion::GlTPSDeformation::clone ( ) const
overridevirtual

Returns a copy of the deformation.

Implements ImFusion::Deformation.

◆ dimension()

int ImFusion::GlTPSDeformation::dimension ( ) const
overridevirtual

Dimension of the deformation.

Implements ImFusion::Deformation.

◆ setPointCorrespondences()

void ImFusion::GlTPSDeformation::setPointCorrespondences ( const std::vector< vec3 > & pts1,
const std::vector< vec3 > & pts2 )

Set point correspondences.

This is equivalent to setting the control points to the first correspondence and setting the displacement to the vector to the second correspondence

◆ setDefaultControlPoints()

void ImFusion::GlTPSDeformation::setDefaultControlPoints ( SharedImage * img,
bool fit = false )

Set the four (in 2D) or eight (in 3D) default control points in the image corners, optionally fitting it to the content.

If the fit parameter is true, the minimum bounding box of the non-zero image content will be used to place the control points.

◆ controlPoints()

std::vector< vec3 > ImFusion::GlTPSDeformation::controlPoints ( ) const
overridevirtual

Get current control points.

Reimplemented from ImFusion::ParametricDeformation.

◆ displacement()

vec3 ImFusion::GlTPSDeformation::displacement ( const vec3 & pos) const
overridevirtual

Get displacement at given point.

Implements ImFusion::Deformation.

◆ setIncludeArguments()

int ImFusion::GlTPSDeformation::setIncludeArguments ( GL::Program & p,
const SharedImage * img = nullptr,
const std::string & prefix = "deform" ) const
overridevirtual

Initializes the FFDeformation shader header to deform the given image.

The displacements are computed from the texture coordinates of the image and are returned in image coordinates, therefore this method should be called again when the displacement should be computed on an image with different extent.

Implements ImFusion::Deformation.

◆ setDisplacement()

void ImFusion::GlTPSDeformation::setDisplacement ( const std::vector< vec3f > & d)
overridevirtual

Set displacement in world coordinate units for every control points.

For 2D images the z-coordinate of the displacement is ignored.

Reimplemented from ImFusion::ParametricDeformation.

◆ displacements()

std::vector< vec3f > ImFusion::GlTPSDeformation::displacements ( ) const
overridevirtual

Get displacement in world coordinate units of all control points.

Reimplemented from ImFusion::ParametricDeformation.

◆ numberOfControlPoints()

int ImFusion::GlTPSDeformation::numberOfControlPoints ( ) const
overridevirtual

Returns the number of control points.

Reimplemented from ImFusion::ParametricDeformation.

◆ isIdentity()

bool ImFusion::GlTPSDeformation::isIdentity ( ) const
overridevirtual

Returns if the current state of the deformation transformations the image or not.

Implements ImFusion::Deformation.

◆ setIdentity()

void ImFusion::GlTPSDeformation::setIdentity ( )
overridevirtual

Sets the displacement of all control points to zero.

Implements ImFusion::Deformation.

◆ configure()

void ImFusion::GlTPSDeformation::configure ( const Properties * p)
overridevirtual

Set one or multiple properties.

Reimplemented from ImFusion::Configurable.

◆ configuration()

void ImFusion::GlTPSDeformation::configuration ( Properties * p) const
overridevirtual

Retrieve the properties of this object.

Reimplemented from ImFusion::Configurable.

◆ id()

std::string ImFusion::GlTPSDeformation::id ( ) const
inlineoverridevirtual

Returns a unique string identifier for this type of deformation.

Usually the name of the class.

Note
To avoid conflicts make sure to include potential plugin names into this ID. Due to the modular architecture of the ImFusion library, uniqueness of IDs cannot be checked at compile time. However, DeformationFactory will check the uniqueness of the ID during registration.
See also
DeformationFactory

Implements ImFusion::Deformation.


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