This is a Python library for computing Harmonic Beltrami Signature(HBS). It provides a set of tools for boundary conditions, mesh generation, conformal welding and other mathematical problems, particularly suited for numerical computations in complex analysis.
This implementation is based on the paper:
Harmonic Beltrami Signature: A Novel 2D Shape Representation for Object Classification
Chenran Lin, Lok Ming Lui
DOI: 10.1137/22M1470852
Install directly from PyPI:
pip install hbsOr install from source:
- Clone this repository:
git clone https://github.com/ChanceAroundYou/hbs_python.git
- Install dependencies:
pip install -r requirements.txt
hbs.py: HBS algorithm for computing HBS and recontructing shape from HBSconformal_welding.py: Conformal welding algorithm implementationmesh.py: Mesh generation and processingutils/:boundary.py: Boundary processing toolsgeodesic_welding.py: Geodesic weldingmobius.py: Möbius transformationspoisson.py: Poisson integral implementationtool_functions.py: Utility functionszipper.py: Zipper algorithm implementation
qc/: Quasiconformal mapping algorithmsbc.py: Beltrami coefficient computationlsqc.py: Least squares quasiconformal mapping algorithm
Compute HBS from image
from hbs.utils.boundary import get_boundary
from hbs import get_hbs
# Boundary points extraction
#
# we don't actually restrict the method of boundary extraction,
# but this package provides a simple implementation as follows
img_path = 'img/example.jpg'
circle_point_num = 1000
bound = get_boundary(img_path, bound_point_num)
# HBS computing
#
# it requires boundary points arranged in clockwise order as input, in `np.complex`
density = 0.01
bound_point_num = 250
hbs, hbs_mapping, cw, disk = get_hbs(bound, circle_point_num, density)Reconstruct shape from HBS
from hbs import reconstruct_from_hbs
## `disk` must be a DiskMesh corresponding to give `hbs`
bound, _, _, _ = reconstruct_from_hbs(hbs, disk)Compute conformal welding from image
from hbs.utils.boundary import get_boundary
from hbs.conformal_welding import get_conformal_welding
# Boundary points extraction
img_path = 'img/example.jpg'
bound_point_num = 250
bound = get_boundary(img_path, bound_point_num)
# Conformal welding computing
#
# it also requires boundary points arranged in clockwise order as input, in `np.complex`
cw = get_conformal_welding(bound)Please also refer to example.ipynb
- NumPy
- SciPy
- Matplotlib
- Opencv
Contributions are welcome via pull requests.
- Chenran Lin