This is a lightweight implementation of "Instant Transport Maps on 2D Grids" [1].
It currently supports L2-optimal maps from an arbitrary density defined on a uniform 2D grid (aka an image) to a square with uniform density. Inverse maps and maps between pairs of arbitrary images are then recovered through numerical inversion and composition resulting in density preserving but approximately optimal maps.
This code comes with 3 demos:
- otmap: computes the forward and backward maps between one image and a uniform square or between a pair of images. The maps are exported as .off quad meshes.
- stippling: adapt a uniformly distributed point cloud to a given image.
- barycenters: computes linear (resp. bilinear) approximate Wasserstein barycenters between a pair (resp. four) images.
$ ./barycenters -in ../data/shape?instant.png -blur 5 -steps 4 -inv -img_eps 1e-3 -th 1e-7 -out shape
$ ./stippling -in ../data/julia.png
This code uses Eigen, Surface_mesh, and CImg that are already included in the repo/archive. It is however highly recommended to install SuiteSparse/Cholmod for higher performance, and libpng/libjpg for image IO.
All you need is to clone the repo, configure a build directory with cmake, and then build. For instance:
$ git clone ...
$ cd otmap
$ mkdir build
$ cd build
$ cmake ..
$ make -j 8
The core of the transport solver is provided under the GNU Public License v3.
Utilities and applications are released under the Mozilla Public License 2.
[1] Georges Nader and Gael Guennebaud. Instant Transport Maps on 2D Grids. ACM Transactions on Graphics (Proceedings of Siggraph Asia 2018). [pdf] [video]