All studies

Moving least squares

Moving least squares

Pin an image in place, pull one point, and watch the surrounding shape bend through a field of local transformations.

JavaScript · Canvas · Web Workers · Moving least squares

View source on GitHub

Try it

Runs locally in your browser. Uploaded images stay on your device.

Selected pin
All processing stays in your browser. Image uploads are resized to a 320px preview.

Drag a pin to deform the image. Double-click to add one. The selected pin also has keyboard-accessible position controls.

Source image
Source image
Precomputed Moving least squares example
Computed example · run to make your own

Ready when you are.

Worker processing · local inputs · downloadable output

How it works

Drag a pin to deform the image. Double-click to add one. The selected pin also has keyboard-accessible position controls.

  1. Give nearby control points more influence than distant ones.
  2. Solve a weighted rigid, similarity, or affine transformation separately at each mesh vertex.
  3. Warp a triangle mesh forward and resample its pixels, keeping control points interpolated.

Read the original research
Schaefer, McPhail & Warren · 2006

Computed examples

Outputs from the same implementation used in the playground.

Original fox portrait used by the algorithm
Fox portrait · generated input
An animal portrait bent around draggable control points
Deformed image · local transformations around control points

Source photographs were generated for these studies. The displayed results were computed by the algorithms; they are not generated illustrations of an expected result. Published previews are compressed for the web.

Implementation and limits

The continuous deformation is approximated by a triangulated image mesh. Extreme crossed pins can fold the mesh; uncovered regions stay transparent.

Interactive settings are bounded to keep the experiment practical in a browser. Higher detail can cost more processing time without guaranteeing a better result. The implementation and its tests are available in the source repository.