In [ ]:
import numpy as np
from menpo.transform import ThinPlateSplines
from menpo.shape import PointCloud
In [ ]:
# landmarks used in Principal Warps paper
src_landmarks = np.array([[3.6929, 10.3819],
[6.5827, 8.8386],
[6.7756, 12.0866],
[4.8189, 11.2047],
[5.6969, 10.0748]])
tgt_landmarks = np.array([[3.9724, 6.5354],
[6.6969, 4.1181],
[6.5394, 7.2362],
[5.4016, 6.4528],
[5.7756, 5.1142]])
In [ ]:
# deformed diamond
src_landmarks = np.array([[ 0, 1.0],
[-1, 0.0],
[ 0,-1.0],
[ 1, 0.0]])
tgt_landmarks = np.array([[ 0, 0.75],
[-1, 0.25],
[ 0,-1.25],
[ 1, 0.25]])
In [ ]:
src = PointCloud(src_landmarks)
tgt = PointCloud(tgt_landmarks)
tps = ThinPlateSplines(src, tgt)
In [ ]:
%matplotlib inline
tps.view()
In [ ]:
np.allclose(tps.apply(src_landmarks), tgt_landmarks)