![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlTPSDeformation.h>
The GlTPSDeformation class provides deformations using a thin-plate splines (TPS). More...
The GlTPSDeformation class provides deformations using a thin-plate splines (TPS).
Public Member Functions | |
GlTPSDeformation (int dimension) | |
GlTPSDeformation (SharedImage *img) | |
GlTPSDeformation (const GlTPSDeformation &other) | |
Deformation * | clone () 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 GlImage * | displacementTexture () const |
const GlImage * | controlPointTexture () 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. | |
![]() | |
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. | |
![]() | |
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< SharedImageSet > | supportingImages () const |
Returns the images that, together with the configuration, defines the deformation. | |
![]() | |
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::string & | defineName () const |
Returns the name of define used by this include. | |
const std::string & | includePath () 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. | |
![]() | |
std::shared_ptr< MultiIncludeType > | createMultiInclude (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). | |
![]() | |
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. | |
GlImage * | m_texDisp |
Displacement texture (same content as m_disp) | |
Eigen::MatrixXd | m_W |
GlImage * | m_texParameters |
GlImage * | m_texControlPoints |
int | m_dimension |
double | m_lambda |
bool | m_useLocal |
![]() | |
bool | m_disabled |
Disabled flag for visualization. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
Additional Inherited Members | |
![]() | |
using | MultiIncludeType |
Alias for type of a multi-include instance of the original include. | |
![]() | |
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) | |
![]() | |
Signal< const DeformationEvent & > | signalChanged |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
void | notifyListeners (const DeformationEvent &event) const |
convenience function to call signalChanged.emitSignal(event) . | |
![]() | |
MultiIncludable (Deformation *crtpInstance, const std::string &baseToken, Flags< ShaderTextReplacement > replacementScheme) | |
Instantiate and configure the MultiIncludable interface. | |
|
overridevirtual |
Returns a copy of the deformation.
Implements Deformation.
|
overridevirtual |
Dimension of the deformation.
Implements Deformation.
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
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.
|
overridevirtual |
Get current control points.
Reimplemented from ParametricDeformation.
|
overridevirtual |
Get displacement at given point.
Implements Deformation.
|
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.
|
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.
|
overridevirtual |
Get displacement in world coordinate units of all control points.
Reimplemented from ParametricDeformation.
|
overridevirtual |
Returns the number of control points.
Reimplemented from ParametricDeformation.
|
overridevirtual |
Returns if the current state of the deformation transformations the image or not.
Implements Deformation.
|
overridevirtual |
Sets the displacement of all control points to zero.
Implements Deformation.
|
overridevirtual |
Set one or multiple properties.
Reimplemented from Configurable.
|
overridevirtual |
Retrieve the properties of this object.
Reimplemented from Configurable.
|
inlineoverridevirtual |
Returns a unique string identifier for this type of deformation.
Usually the name of the class.
Implements Deformation.