lapy.conformal¶
Computes spherical conformal mappings of triangle meshes.
Functions are adopted from Matlab code at https://github.com/garyptchoi/spherical-conformal-map with this Copyright (c) 2013-2020, Gary Pui-Tung Choi https://math.mit.edu/~ptchoi and has been distributed with the Apache 2 License.
Notes¶
If you use this code in your own work, please cite the following paper:
[1] P. T. Choi, K. C. Lam, and L. M. Lui, “FLASH: Fast Landmark Aligned Spherical Harmonic Parameterization for Genus-0 Closed Brain Surfaces.” SIAM Journal on Imaging Sciences, vol. 8, no. 1, pp. 67-94, 2015.
- lapy.conformal.beltrami_coefficient(tria, mapping)¶
Compute the Beltrami coefficient of a given mapping.
The Beltrami coefficient is a complex-valued function that characterizes the distortion of a mapping in terms of conformality.
- Parameters:
- tria
TriaMesh
Genus-0 closed triangle mesh. Should be planar mapping on complex plane.
- mapping
np.ndarray
A numpy array of shape (n, 3) representing the coordinates of the spherical conformal parameterization.
- tria
- Returns:
- mu
np.ndarray
Complex Beltrami coefficient per triangle.
- mu
- lapy.conformal.inverse_stereographic(u)¶
Compute mapping from the complex plane to the sphere using the inverse stereographic projection.
- Parameters:
- Returns:
- np.ndarray:
A numpy array of shape (n, 3) containing the mapped points on the sphere as (x, y, z) coordinates.
- lapy.conformal.linear_beltrami_solver(tria, mu, landmark, target, use_cholmod=False)¶
Solve the Linear Beltrami equation for a given mesh and target.
- Parameters:
- tria
TriaMesh
Genus-0 closed triangle mesh. Should be planar mapping on complex plane.
- mu
np.ndarray
A numpy array containing Beltrami coefficients, describing distortion at each vertex.
- landmark
np.ndarray
A numpy array of indices specifying the fixed landmark vertices.
- target
np.ndarray
- A numpy array of shape (len(landmark), 2), specifying the 2D target positions
for the landmark vertices.
- use_cholmod
bool
, default=False - Which solver to use:
True : Attempt to use Cholesky decomposition from scikit-sparse cholmod.
False: Use spsolve (LU decomposition).
- tria
- Returns:
- mapping
np.ndarray
- An array of shape (n, 2) representing the mapping of all vertices in the
triangulation to 2D coordinates, aligned to the given landmarks.
- mapping
- lapy.conformal.mobius_area_correction_spherical(tria, mapping)¶
Find an improved Mobius transformation to reduce distortion.
This helps reducing the area distortion of a spherical conformal parameterization using the method in Choi et al, SIAM Journal on Imaging Sciences, 2020.
- Parameters:
- tria
TriaMesh
Genus-0 closed triangle mesh.
- mapping
np.ndarray
A NumPy array of shape (n, 3) representing vertex coordinates of a spherical conformal parameterization.
- tria
- Returns:
- map_mobius:
np.ndarray
A NumPy array of shape (n, 3) with vertex coordinates updated to minimize area distortion.
- result:
np.ndarray
Optimal parameters (x) for the Mobius transformation, where
\[f(z) = \frac{az+b}{cz+d} = \frac{(x(1)+x(2)*1j)*z+(x(3)+x(4)*1j)}{(x(5)+x(6)*1j)*z+(x(7)+x(8)*1j)}.\]
- map_mobius:
- lapy.conformal.spherical_conformal_map(tria, use_cholmod=False)¶
Linear method for computing spherical conformal map of a genus-0 closed surface.
- Parameters:
- Returns:
- mapping:
np.ndarray
Vertex coordinates as NumPy array of shape (n, 3) of the spherical conformal parameterization.
- mapping:
- lapy.conformal.stereographic(u)¶
Map points on a sphere to the complex plane using the stereographic projection.
- Parameters:
- u
np.ndarray
A numpy array of shape (n, 3), where each row represents a point on the sphere as (x, y, z) coordinates.
- u
- Returns:
- np.ndarray:
A numpy array of shape (n,) containing the mapped points as complex numbers on the complex plane.