Class ImageDeformPointMLS_F32

java.lang.Object
boofcv.alg.distort.mls.ImageDeformPointMLS_F32
All Implemented Interfaces:
Point2Transform2_F32

public class ImageDeformPointMLS_F32
extends Object
implements Point2Transform2_F32

Implementation of 'Moving Least Squares' (MLS) control point based image deformation models described in [1].

Usage Procedure:
  1. Invoke configure(int, int, int, int)
  2. Invoke addControl(float, float) for each control point
  3. Invoke setDistorted(int, float, float) to change the distorted location of a control point
  4. 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:

  1. 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.
  2. 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.

  • Constructor Details

    • ImageDeformPointMLS_F32

      public ImageDeformPointMLS_F32​(TypeDeformMLS type)
    • 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 width
      height - Image height
      gridRows - grid rows
      gridCols - 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 pixels
      y - 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 pixels
      y - 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 coordinate
      srcY - distorted coordinate
      dstX - undistorted coordinate
      dstY - 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 point
      x - distorted coordinate x-axis in image pixels
      y - 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

      public void compute​(float x, float y, Point2D_F32 out)
      Description copied from interface: Point2Transform2_F32
      Applies transformation
      Specified by:
      compute in interface Point2Transform2_F32
      Parameters:
      x - x-coordinate of point
      y - y-coordinate of point
      out - Transformed point location.
    • copyConcurrent

      public ImageDeformPointMLS_F32 copyConcurrent()
      Description copied from interface: Point2Transform2_F32
      Creates 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 to Point2Transform2_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:
      copyConcurrent in interface Point2Transform2_F32
    • getAlpha

      public float getAlpha()
    • setAlpha

      public void setAlpha​(float alpha)