Note
Go to the end to download the full example code
Multiscaling and landmarks
The skshapes.Multiscale
class
preserves landmarks across scales.
import pyvista as pv
import skshapes as sks
To demonstrate this, we first load a mesh with a collection of key points.
mesh = sks.PolyData(pv.examples.download_louis_louvre().clean())
landmarks = [151807, 21294, 23344, 25789, 131262, 33852, 171465, 191680]
landmarks += [172653, 130895, 9743, 19185, 143397, 200885]
mesh.landmark_indices = landmarks
Then, we compute a multiscale representation of our mesh using 10%, 1% and 0.1% of the original point count.
ratios = [1, 0.1, 0.01, 0.001]
multiscale = sks.Multiscale(shape=mesh, ratios=ratios)
The landmark_points
and
landmark_indices
attributes of the shape
are transported consistently between the different scales.
pl = pv.Plotter()
pl.open_gif("animation.gif", fps=1)
for ratio in ratios:
mesh_i = multiscale.at(ratio=ratio)
print(f"with {mesh_i.n_points:,d} points, landmarks = ")
print([int(i) for i in mesh_i.landmark_indices])
pl.clear_actors()
sks.doc.display(plotter=pl, shape=mesh_i)
sks.doc.display(plotter=pl, shape=mesh_i.landmark_points, color="red")
pl.camera_position = "xz"
pl.camera.zoom(1.4)
pl.write_frame()
pl.show()

with 210,873 points, landmarks =
[151807, 21294, 23344, 25789, 131262, 33852, 171465, 191680, 172653, 130895, 9743, 19185, 143397, 200885]
with 21,067 points, landmarks =
[14747, 1615, 2465, 10164, 16549, 3281, 16824, 18981, 16971, 5351, 943, 1778, 13775, 16290]
with 2,087 points, landmarks =
[144, 181, 205, 203, 1630, 336, 1659, 1690, 1090, 1202, 73, 157, 1917, 1566]
with 188 points, landmarks =
[19, 84, 20, 17, 28, 27, 147, 33, 32, 184, 12, 126, 169, 137]
Total running time of the script: (0 minutes 29.846 seconds)