pyFM.functional¶
Classes
|
A class to compute functional maps between two meshes |
- class pyFM.functional.FunctionalMapping(mesh1, mesh2)¶
A class to compute functional maps between two meshes
- descr1¶
(n1,p) descriptors on the first mesh
- descr2¶
(n2,p) descriptors on the second mesh
- D_a¶
(k1,k1) area-based shape differnence operator
- D_c¶
(k1,k1) conformal-based shape differnence operator
- FM_type¶
‘classic’ | ‘icp’ | ‘zoomout’ which FM is currently used
- k1¶
dimension of the first eigenspace (varies depending on the type of FM)
- k2¶
dimension of the seconde eigenspace (varies depending on the type of FM)
- FM¶
(k2,k1) current FM
- p2p_21¶
(n2,) point to point map associated to the current functional map
- property k1¶
” Return the input dimension of the functional map
- Returns:
k1 – dimension of the first eigenspace
- Return type:
int
- property k2¶
Return the output dimension of the functional map
- Returns:
k2 – dimension of the second eigenspace
- Return type:
int
- property FM_type¶
Returns the type of functional map currently used
- Returns:
FM_type – ‘classic’ | ‘icp’ | ‘zoomout’
- Return type:
str
- change_FM_type(FM_type)¶
Changes the type of functional map to use
- Parameters:
FM_type (str) – ‘classic’ | ‘icp’ | ‘zoomout’
- property FM¶
Returns the current functional map depending on the value of FM_type
- Returns:
(k2,k1) current FM
- Return type:
FM
- property preprocessed¶
check if enough information is provided to fit the model
- Returns:
preprocessed – whether the model is preprocessed
- Return type:
bool
- property fitted¶
check if the model has been fitted
- Returns:
fitted – whether the model is fitted
- Return type:
bool
- get_p2p(use_adj=False, n_jobs=1)¶
Computes a vertex to vertex map from mesh2 to mesh1
- Parameters:
use_adj (bool) – whether to use the adjoint map.
n_jobs – number of parallel jobs. Use -1 to use all processes
Outputs
--------------------------
p2p_21 – (n2,) match vertex i on shape 2 to vertex p2p_21[i] on shape 1
- get_precise_map(precompute_dmin=True, use_adj=True, batch_size=None, n_jobs=1, verbose=False)¶
Returns a precise map from mesh2 to mesh1
See [1] for details on notations.
[1] - “Deblurring and Denoising of Maps between Shapes”, by Danielle Ezuz and Mirela Ben-Chen.
- Parameters:
precompute_dmin – Whether to precompute all the values of delta_min. Faster but heavier in memory
use_adj – use the adjoint method
batch_size – If precompute_dmin is False, projects batches of points on the surface
n_jobs – number of parallel process for nearest neighbor precomputation
- Returns:
P21 – (n2,n1) sparse - precise map from mesh2 to mesh1
- Return type:
scipy.sparse.csr_matrix
- preprocess(n_ev=(50, 50), n_descr=100, descr_type='WKS', landmarks=None, subsample_step=1, k_process=None, verbose=False)¶
Saves the information about the Laplacian mesh for opt
- Parameters:
n_ev (tuple) – (k1, k2) tuple - with the number of Laplacian eigenvalues to consider.
n_descr (int) – number of descriptors to consider
descr_type (str) – “HKS” | “WKS”
landmarks (np.ndarray, optional) –
- (p,1|2) array of indices of landmarks to match.
If (p,1) uses the same indices for both.
subsample_step (int) – step with which to subsample the descriptors.
k_process (int) – number of eigenvalues to compute for the Laplacian spectrum
- fit(w_descr=0.1, w_lap=0.001, w_dcomm=1, w_orient=0, orient_reversing=False, optinit='zeros', verbose=False)¶
Solves the functional map optimization problem :
\(\min_C \mu_{descr} \|C A - B\|^2 + \mu_{descr comm} \sum_i \|CD_{A_i} - D_{B_i} C \|^2 + \mu_{lap} \|C L_1 - L_2 C\|^2\) \(+ \mu_{orient} * \sum_i \|C G_{A_i} - G_{B_i} C\|^2\)
with A and B descriptors, D_Ai and D_Bi multiplicative operators extracted from the i-th descriptors, L1 and L2 laplacian on each shape, G_Ai and G_Bi orientation preserving (or reversing) operators association to the i-th descriptors.
- Parameters:
w_descr (float) – scaling for the descriptor preservation term
w_lap (float) – scaling of the laplacian commutativity term
w_dcomm (float) – scaling of the multiplicative operator commutativity
w_orient – scaling of the orientation preservation term (in addition to relative scaling with the other terms as in the original code)
orient_reversing – Whether to use the orientation reversing term instead of the orientation preservation one
optinit – ‘random’ | ‘identity’ | ‘zeros’ initialization. In any case, the first column of the functional map is computed by hand and not modified during optimization
- icp_refine(nit=10, tol=None, use_adj=False, overwrite=True, verbose=False, n_jobs=1)¶
Refines the functional map using ICP and saves the result
- Parameters:
nit (int) – number of iterations of icp to apply
tol (float) –
- threshold of change in functional map in order to stop refinement
(only applies if nit is None)
overwrite (bool) –
- If True changes FM type to ‘icp’ so that next call of self.FM
will be the icp refined FM
- zoomout_refine(nit=10, step=1, subsample=None, overwrite=True, verbose=False)¶
Refines the functional map using ZoomOut and saves the result
- Parameters:
nit (int) – number of iterations to do
step (int) – increase in dimension at each Zoomout Iteration
subsample (int) – number of points to subsample for ZoomOut. If None or 0, no subsampling is done.
overwrite (bool) – If True changes FM type to ‘zoomout’ so that next call of self.FM will be the zoomout refined FM (larger than the other 2)
- compute_SD()¶
Compute the shape difference operators associated to the functional map
- get_x0(optinit='zeros')¶
Returns the initial functional map for optimization.
- Parameters:
optinit (str) – ‘random’ | ‘identity’ | ‘zeros’ initialization. In any case, the first column of the functional map is computed by hand and not modified during optimization
- Returns:
x0 – corresponding initial vector
- Return type:
np.ndarray
- compute_descr_op()¶
Compute the multiplication operators associated with the descriptors
- Returns:
operators – n_descr long list of ((k1,k1),(k2,k2)) operators.
- Return type:
list
- compute_orientation_op(reversing=False, normalize=False)¶
Compute orientation preserving or reversing operators associated to each descriptor.
- Parameters:
reversing (bool) –
- whether to return operators associated to orientation inversion instead
of orientation preservation (return the opposite of the second operator)
normalize (bool) –
- whether to normalize the gradient on each face. Might improve results
according to the authors
- Returns:
list_op – (n_descr,) where term i contains (D1,D2) respectively of size (k1,k1) and (k2,k2) which represent operators supposed to commute.
- Return type:
list
- project(func, k=None, mesh_ind=1)¶
Projects a function on the LB basis
- Parameters:
func (array) – (n1|n2,p) evaluation of the function
mesh_in (int) – 1 | 2 index of the mesh on which to encode
- Returns:
encoded_func – (n1|n2,p) array of decoded f
- Return type:
np.ndarray
- decode(encoded_func, mesh_ind=2)¶
Decode a function from the LB basis
- Parameters:
encoded_func (array) – (k1|k2,p) encoding of the functions
mesh_ind (int) – 1 | 2 index of the mesh on which to decode
- Returns:
func – (n1|n2,p) array of decoded f
- Return type:
np.ndarray
- transport(encoded_func, reverse=False)¶
transport a function from LB basis 1 to LB basis 2. If reverse is True, then the functions are transposed the other way using the transpose of the functional map matrix
- Parameters:
encoded_func (array) – (k1|k2,p) encoding of the functions
reverse – bool If true, transpose from 2 to 1 using the transpose of the FM
- Returns:
transp_func – (n2|n1,p) array of new encoding of the functions
- Return type:
np.ndarray
- transfer(func, reverse=False)¶
Transfer a function from mesh1 to mesh2. If ‘reverse’ is set to true, then the transfer goes the other way using the transpose of the functional map as approximate inverser transfer.
- Parameters:
func – (n1|n2,p) evaluation of the functons
- Returns:
transp_func – (n2|n1,p) transfered function
- Return type:
np.ndarray