pyFM.functional¶
Classes
|
Compute a functional map between two meshes. |
- class pyFM.functional.FunctionalMapping(mesh1, mesh2)¶
Compute a functional map between two meshes.
Typical workflow:
model = FunctionalMapping(mesh1, mesh2) model.preprocess(n_ev=(50, 50), descr_type='WKS') model.fit() # sets model.FM p2p = model.get_p2p() # from model.FM FM_icp = model.icp_refine() p2p_icp = model.get_p2p(FM_icp)
- FM¶
Functional map set by fit(). Refinement methods return a new FM rather than overwriting this one.
- Type:
(k2, k1) ndarray or None
- descr1, descr2
Descriptors set by preprocess().
- Type:
(n, p) ndarray or None
- get_p2p(FM=None, use_adj=False, n_jobs=1)¶
Compute a pointwise map from mesh2 to mesh1.
- Parameters:
FM ((k2, k1) ndarray, optional) – Functional map to convert. Defaults to self.FM.
use_adj (bool) – Whether to use the adjoint map.
n_jobs (int) – Number of parallel jobs for nearest-neighbour search.
- Returns:
p2p_21 – p2p_21[i] is the index on mesh1 corresponding to vertex i on mesh2.
- Return type:
(n2,) ndarray
- get_precise_map(FM=None, precompute_dmin=True, use_adj=True, batch_size=None, n_jobs=1, verbose=False)¶
Compute a precise (barycentric) map from mesh2 to mesh1.
See “Deblurring and Denoising of Maps between Shapes” (Ezuz & Ben-Chen).
- Parameters:
FM ((k2, k1) ndarray, optional) – Functional map to convert. Defaults to self.FM.
precompute_dmin (bool) – Precompute all delta_min values. Faster but heavier in memory.
use_adj (bool)
batch_size (int, optional)
n_jobs (int)
verbose (bool)
- Returns:
P21
- Return type:
(n2, n1) sparse matrix
- preprocess(K=50, n_descr=100, descr_type='WKS', landmarks=None, subsample_step=1, k_process=None, verbose=False)¶
Compute the LBO spectrum and descriptors needed for fit().
- Parameters:
K (int or (int, int)) – Number of LBO eigenvectors to keep for each mesh.
n_descr (int) – Number of descriptor values per mesh.
descr_type ("WKS" | "HKS")
landmarks ((p,) or (p, 2) ndarray, optional) – Landmark indices. Shape (p,) uses the same indices on both meshes; shape (p, 2) uses column 0 for mesh1 and column 1 for mesh2.
subsample_step (int) – Keep every nth descriptor column.
k_process (int, optional) – Number of eigenvalues to compute (default 200).
verbose (bool)
- fit(w_descr=0.1, w_lap=0.001, w_dcomm=1, w_orient=0, orient_reversing=False, optinit='zeros', verbose=False)¶
Solve the functional map optimization and store the result in self.FM.
Minimises:
w_descr * ||C A - B||² + w_lap * ||C L1 - L2 C||² (LBO commutativity) + w_dcomm * Σ_i ||C D_Ai - D_Bi C||² (descriptor commutativity) + w_orient * Σ_i ||C G_Ai - G_Bi C||² (orientation term)
Calls preprocess() automatically if it has not been done yet.
- Parameters:
w_descr (float)
w_lap (float)
w_dcomm (float)
w_orient (float) – Set to 0 to disable the orientation term.
orient_reversing (bool) – Use orientation-reversing instead of orientation-preserving operators.
optinit ("zeros" | "identity" | "random")
verbose (bool)
- icp_refine(FM=None, nit=10, tol=None, use_adj=False, n_jobs=1, verbose=False)¶
Refine a functional map with ICP.
- Parameters:
FM ((k2, k1) ndarray, optional) – FM to refine. Defaults to self.FM.
nit (int)
tol (float, optional)
use_adj (bool)
n_jobs (int)
verbose (bool)
- Returns:
FM_icp
- Return type:
(k2, k1) ndarray
- zoomout_refine(FM=None, nit=10, step=1, subsample=None, verbose=False)¶
Refine a functional map with ZoomOut.
- Parameters:
FM ((k2, k1) ndarray, optional) – FM to refine. Defaults to self.FM.
nit (int)
step (int) – Dimension increase per iteration.
subsample (int, optional) – Number of vertices to subsample via FPS. None means no subsampling.
verbose (bool)
- Returns:
FM_zo
- Return type:
(k2 + nit*step, k1 + nit*step) ndarray
- compute_SD()¶
Compute area- and conformal-based shape difference operators. Stores results in self.SD_a and self.SD_c.
- project(func, k=None, mesh_ind=1)¶
Project a function onto the LBO basis.
- Parameters:
func ((n, p) ndarray)
k (int, optional — number of coefficients (default: k1 or k2))
mesh_ind (1 | 2)
- Returns:
coeffs
- Return type:
(k, p) ndarray
- decode(coeffs, mesh_ind=2)¶
Reconstruct a function from LBO coefficients.
- Parameters:
coeffs ((k, p) ndarray)
mesh_ind (1 | 2)
- Returns:
func
- Return type:
(n, p) ndarray
- transport(coeffs, reverse=False)¶
Apply the functional map to spectral coefficients.
- Parameters:
coeffs ((k1, p) ndarray (or (k2, p) if reverse=True))
reverse (bool — use FM.T to go from basis 2 → basis 1)
- Returns:
transported
- Return type:
(k2, p) or (k1, p) ndarray
- transfer(func, reverse=False)¶
Transfer a function between meshes (project → transport → decode).
- Parameters:
func ((n1, p) ndarray (or (n2, p) if reverse=True))
reverse (bool — transfer from mesh2 to mesh1 via FM.T)
- Returns:
transferred
- Return type:
(n2, p) or (n1, p) ndarray