ImFusion SDK 4.3
GlTPSDeformation Class Reference

#include <ImFusion/GL/GlTPSDeformation.h>

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

+ Inheritance diagram for 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 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 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 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 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 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
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (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 Deformation
bool m_disabled
 Disabled flag for visualization.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Additional Inherited Members

- Public Types inherited from MultiIncludable< Deformation, const SharedImage * >
using MultiIncludeType
 Alias for type of a multi-include instance of the original include.
 
- Static Public Member Functions inherited from 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 Deformation
Signal< const DeformationEvent & > signalChanged
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 
- Protected Member Functions inherited from Deformation
void notifyListeners (const DeformationEvent &event) const
 convenience function to call signalChanged.emitSignal(event).
 
- Protected Member Functions inherited from 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 * clone ( ) const
overridevirtual

Returns a copy of the deformation.

Implements Deformation.

◆ dimension()

int dimension ( ) const
overridevirtual

Dimension of the deformation.

Implements Deformation.

◆ setPointCorrespondences()

void 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 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 > controlPoints ( ) const
overridevirtual

Get current control points.

Reimplemented from ParametricDeformation.

◆ displacement()

vec3 displacement ( const vec3 & pos) const
overridevirtual

Get displacement at given point.

Implements Deformation.

◆ setIncludeArguments()

int 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 Deformation.

◆ setDisplacement()

void 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 ParametricDeformation.

◆ displacements()

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

Get displacement in world coordinate units of all control points.

Reimplemented from ParametricDeformation.

◆ numberOfControlPoints()

int numberOfControlPoints ( ) const
overridevirtual

Returns the number of control points.

Reimplemented from ParametricDeformation.

◆ isIdentity()

bool isIdentity ( ) const
overridevirtual

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

Implements Deformation.

◆ setIdentity()

void setIdentity ( )
overridevirtual

Sets the displacement of all control points to zero.

Implements Deformation.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Set one or multiple properties.

Reimplemented from Configurable.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieve the properties of this object.

Reimplemented from Configurable.

◆ id()

std::string 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 Deformation.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close