mesh-signatures
mesh-signatures copied to clipboard
A small project implementing different per-vertex mesh signatures.
Mesh Signatures
🚩 Disclaimer: The project is no longer maintained by me. It was implemented years ago during my PhD. By now, I have forgotten most of the theory and details of the implementation. So, fixing bugs is a time investment I am not willing to make right now.
This is a small project implementing mesh signatures for triangle meshes in python. We currently implement two signatures:
- Heat-Kernel-Signature
- Wave-Kernel-Signature
Signature extractor
The core functionality is implemented in the two files signature.py and laplace.py. Both heat and wave signatures are require the eigenvectors and eigenvalues of the generalized eigenvector problem
, where
is the Laplace operator defined on the triangle mesh.
A is a diagonal matrix with areas associated with the area of vertices. W defines the approximation of the laplace operator (see next section).
You can easily compute the signatures of every vertex in a mesh like this:
import trimesh
import msig
mesh = trimesh.load("./dragon.obj")
# Compute 100 eigen vectors using laplace-beltrami
extractor = msig.SignatureExtractor(mesh, 100, approx='beltrami')
# extractor = SignatureExtractor(path="./dragon.npz")
extractor.save("./dragon.npz") # Store eigen spectrum
# Compute 128 dimensional wave features
wave_fs = extractor.signatures(128, 'wave')
# Compute 64 dimensional heat features and get time values
heat_fs, ts = extractor.signatures(64, 'heat', return_x_ticks=True)
Discrete Laplace Operator Approximations
An important part of mesh signatures is an approximation of the laplace operator matrix on the triangular mesh (V, E). We implement 4 different versions of this.
- Laplace-Beltrami Matrix
- Cotangens Weighted Matrix
- Mesh Laplace Matrix
- Quadratic FEM
Visualization
We provide a simple visualization, using OpenGL, to play with in the file viz.py
You can use this like this:
python ./viz.py <path_to_mesh>
There is a list of optional parameters:
- --n_basis: Number of eigen values and vectors to compute
- --f_size: Feature size to use
- --approx: Laplace approximation to use. Must be one of beltrami, cotangens, mesh or fem
- --kernel: Feature type to display. Must be one of heat or wave
- --laplace: A .npz file containing precomputed eigen values and vectors.
You can use compute_laplace_spectrum.py to create these files.
Using the Laplace Operator spectrum
The signature extractor class computes the spectrum of the laplace operator. You can use the spectrum for spectral analysis on meshes. We provide an example of this in hamiltonian.py where we visualize the spectrum of the hamiltonian operator on a given masked mesh.
See Hamiltonian operator for spectral shape analysis by Yoni Choukroun et al. for details on the hamiltonian operator.
Required packages
The core signature computation requires:
- numpy and scipy for signature computation
- trimesh for MeshIO
- lapy (optional) for fem laplace approximation
The visualization script requieres
- pyopengl
- pyGLFW
- pyimgui
- imgui_datascience (only used in hamiltonian.py)
- matplotlib
- imageio
References
- A Concise and Provably Informative Multi-Scale Signature Based on Heat Diffusion, Jian Sun et al.
- The Wave Kernel Signature: A Quantum Mechanical Approach to Shape Analysis, Mathieu Aubry et al.
- Pose-Consistent 3D Shape Segmentation Based on a Quantum Mechanical Feature Descriptor, Mathieu Aubry et al.
- Discrete Laplace Operator on Meshed Surfaces, Mikhail Belkin et al.
- Laplace-Beltrami spectra as 'Shape-DNA' of surfaces and solids, Reuter M et al.