pyFM.functional.FunctionalMapping

class pyFM.functional.FunctionalMapping(mesh1, mesh2)

Bases: object

Compute a functional map between two meshes.

Typical workflow:

model = FunctionalMapping(mesh1, mesh2)
model.preprocess(descr_type='WKS')
model.fit(K=(50, 50))                # sets model.FM_12

p2p = model.get_p2p()                # from model.FM_12
FM_icp = model.icp_refine()
p2p_icp = model.get_p2p(FM_icp)
Parameters:
FM_12

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

property FM

Deprecated alias for FM_12.

property preprocessed

Deprecated alias for has_spectral.

project(func, k=None, mesh_ind=1)

Deprecated alias for model.mesh1.project / model.mesh2.project.

decode(coeffs, mesh_ind=2)

Deprecated alias for model.mesh1.unproject / model.mesh2.unproject.

transport(coeffs, reverse=False)

Deprecated, apply FM_12 directly.

get_p2p(FM=None, use_adj=False, n_jobs=None)

Compute a pointwise map from mesh2 to mesh1.

Parameters:
  • FM ((k2, k1) ndarray, optional) – Functional map to convert. Defaults to self.FM_12.

  • 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=None, 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_12.

  • 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

compute_spectral_descriptors(n_descr=100, descr_type='WKS', k_descr=128, landmarks=None, landmarks_only=False, subsample_step=1, normalization='l2')

Compute the LBO spectrum and descriptors needed for fit().

Parameters:
  • n_descr (int) – Number of descriptor values per mesh.

  • descr_type ("WKS" | "HKS" | None) – Built-in descriptor type. Pass None to skip descriptor computation and supply descriptors manually via add_descriptors().

  • 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.

  • landmarks_only (bool) – If True, compute descriptors only at the landmark vertices.

  • subsample_step (int) – Keep every nth descriptor column.

  • k_descr (int, optional) – Number of eigenvalues to compute for descriptor computation (default 128).

  • verbose (bool)

preprocess(n_descr=100, descr_type='WKS', landmarks=None, landmarks_only=False, subsample_step=1, k_process=200, k_descr=128, verbose=False, K=None)

Compute the LBO spectrum and descriptors needed for fit().

Parameters:
  • n_descr (int) – Number of descriptor values per mesh.

  • descr_type ("WKS" | "HKS" | None) – Built-in descriptor type. Pass None to skip descriptor computation and supply descriptors manually via add_descriptors().

  • 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)

  • K (int or (int, int), optional) – Deprecated. The functional map size is now set on fit().

add_descriptors(descr1, descr2, normalize=True)

Append custom descriptors for both meshes.

Can be called after preprocess() to mix custom descriptors with built-in ones, or after preprocess(descr_type=None) for a fully custom descriptor workflow.

Parameters:
  • descr1 ((n1, p) or (n1,) ndarray)

  • descr2 ((n2, p) or (n2,) ndarray)

  • normalize (bool) – L2-normalize each descriptor column using the mesh area metric.

Return type:

self

fit(K=(50, 50), w_descr=0.1, w_lap=0.001, w_dcomm=1, w_orient=0, orient_reversing=False, use_resolvent_laplacian=True, resolvent_gamma=0.5, optinit='zeros', factr=10000000.0, pgtol=1e-05, normalize_weights=True, verbose=False)

Solve the functional map optimization and store the result in self.FM_12.

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)

Only the ratios of the weights matter: they are normalized internally, so multiplying all of them by a common factor leaves the result unchanged.

Calls preprocess() automatically if it has not been done yet.

Parameters:
  • w_descr (float)

  • w_lap (float)

  • w_dcomm (float)

  • w_orient (float) – Relative weight of the orientation term, rescaled internally so that w_orient=1 makes it comparable to the sum of the other terms at C=I. Set to 0 to disable it.

  • orient_reversing (bool) – Use orientation-reversing instead of orientation-preserving operators.

  • optinit ("zeros" | "identity" | "random")

  • factr (float) – L-BFGS-B relative tolerance on the energy decrease. Lower it (e.g. 1e2) for a tighter solve.

  • pgtol (float) – L-BFGS-B tolerance on the max-norm of the projected gradient. This test is absolute, so lower it if the energy is small in absolute terms.

  • verbose (bool)

icp_refine(FM=None, nit=10, tol=1e-10, use_adj=False, n_jobs=None, verbose=False)

Refine a functional map with ICP.

Parameters:
  • FM ((k2, k1) ndarray, optional) – FM to refine. Defaults to self.FM_12.

  • 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_12.

  • 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.

transfer(func)

Transfer a function between meshes (project → transport → decode).

Parameters:

func ((n1, p) ndarray)

Returns:

transferred

Return type:

(n2, p)

Examples using FunctionalMapping

The Laplacian and its spectrum

The Laplacian and its spectrum

Computing a map without a correspondence

Computing a map without a correspondence