Package boofcv.alg.distort.mls
Class ImageDeformPointMLS_F32
java.lang.Object
boofcv.alg.distort.mls.ImageDeformPointMLS_F32
- All Implemented Interfaces:
Point2Transform2_F32
Implementation of 'Moving Least Squares' (MLS) control point based image deformation models described in [1].
Usage Procedure:- Invoke
configure(int, int, int, int) - Invoke
addControl(float, float)for each control point - Invoke
setDistorted(int, float, float)to change the distorted location of a control point - Invoke
fixate()when all control points have been added and after you are done changing distorted locations
Each control point has an undistorted and distorted location. The fixate functions are used to precompute different portions of the deformation to maximize speed by avoiding duplicate computations. Instead of computing a distortion for each pixel a regular grid is used instead. Pixel points are interpolated between grid points using bilinear interpolation.
This should be a faithful implementation of MLS. Potential deviations listed below:
- Pixels should be adjusted when converting to grid coordinates to maintain the same aspect ratio as the input image. This way the results is "independent" of the internal grids shape/size. [1] does not mention this issue.
- When compared against images published in [1] the rigid transform appears slightly different. However, when compared against other implementations those appear to produce nearly identical results to this implementation.
[1] Schaefer, Scott, Travis McPhail, and Joe Warren. "Image deformation using moving least squares." ACM transactions on graphics (TOG). Vol. 25. No. 3. ACM, 2006.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassSee paper section 2.1static classclassPaper section 2.3classSee paper section 2.2 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionintadd(float srcX, float srcY, float dstX, float dstY) Function that let's you set control and undistorted points at the same timeintaddControl(float x, float y) Adds a new control point at the specified location.voidcompute(float x, float y, Point2D_F32 out) Applies transformationvoidconfigure(int width, int height, int gridRows, int gridCols) Specifies the input image size and the size of the grid it will use to approximate the idea solution.Creates a copy of this transform for use in concurrent application.voidfixate()Precompute the portion of the equation which only concerns the undistorted location of each point on the grid even the current undistorted location of each control point.floatgetAlpha()voidreset()Discards all existing control pointsvoidsetAlpha(float alpha) voidsetDistorted(int which, float x, float y) Sets the distorted location of a specific control pointvoidsetUndistorted(int which, float x, float y) Sets the location of a control point.
-
Constructor Details
-
ImageDeformPointMLS_F32
-
ImageDeformPointMLS_F32
protected ImageDeformPointMLS_F32()
-
-
Method Details
-
reset
public void reset()Discards all existing control points -
configure
public void configure(int width, int height, int gridRows, int gridCols) Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded- Parameters:
width- Image widthheight- Image heightgridRows- grid rowsgridCols- grid columns
-
addControl
public int addControl(float x, float y) Adds a new control point at the specified location. Initially the distorted and undistorted location will be set to the same- Parameters:
x- coordinate x-axis in image pixelsy- coordinate y-axis in image pixels- Returns:
- Index of control point
-
setUndistorted
public void setUndistorted(int which, float x, float y) Sets the location of a control point.- Parameters:
x- coordinate x-axis in image pixelsy- coordinate y-axis in image pixels
-
add
public int add(float srcX, float srcY, float dstX, float dstY) Function that let's you set control and undistorted points at the same time- Parameters:
srcX- distorted coordinatesrcY- distorted coordinatedstX- undistorted coordinatedstY- undistorted coordinate- Returns:
- Index of control point
-
setDistorted
public void setDistorted(int which, float x, float y) Sets the distorted location of a specific control point- Parameters:
which- Which control pointx- distorted coordinate x-axis in image pixelsy- distorted coordinate y-axis in image pixels
-
fixate
public void fixate()Precompute the portion of the equation which only concerns the undistorted location of each point on the grid even the current undistorted location of each control point. Recompute the deformation of each point in the internal grid now that the location of control points is not changing any more. -
compute
Description copied from interface:Point2Transform2_F32Applies transformation- Specified by:
computein interfacePoint2Transform2_F32- Parameters:
x- x-coordinate of pointy- y-coordinate of pointout- Transformed point location.
-
copyConcurrent
Description copied from interface:Point2Transform2_F32Creates a copy of this transform for use in concurrent application. What that means is that any variable which might be modified by a concurrent call toPoint2Transform2_F32.compute(float, float, georegression.struct.point.Point2D_F32)is not passed to the 'copied' output. Expensive to compute models might be passed in as a reference.- Specified by:
copyConcurrentin interfacePoint2Transform2_F32
-
getAlpha
public float getAlpha() -
setAlpha
public void setAlpha(float alpha)
-