Skip to main content

Python library for computing Harmonic Beltrami Signature(HBS)

Project description

HBS - Harmonic Beltrami Signature

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.

Reference

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

Installation

Install directly from PyPI:

pip install hbs

Or install from source:

  1. Clone this repository:
    git clone https://github.com/ChanceAroundYou/hbs_python.git
    
  2. Install dependencies:
    pip install -r requirements.txt
    

Main Modules

  • hbs.py: HBS algorithm for computing HBS and recontructing shape from HBS
  • conformal_welding.py: Conformal welding algorithm implementation
  • mesh.py: Mesh generation and processing
  • utils/:
    • boundary.py: Boundary processing tools
    • geodesic_welding.py: Geodesic welding
    • mobius.py: Möbius transformations
    • poisson.py: Poisson integral implementation
    • tool_functions.py: Utility functions
    • zipper.py: Zipper algorithm implementation
  • qc/: Quasiconformal mapping algorithms
    • bc.py: Beltrami coefficient computation
    • lsqc.py: Least squares quasiconformal mapping algorithm

Usage Example

Compute HBS from image

from hbs.utils.boundary import get_boundary
from hbs import get_hbs

img_path = 'img/example.jpg'
circle_point_num = 1000
density = 0.01
bound_point_num = 250
bound = get_boundary(img_path, bound_point_num)

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

img_path = 'img/example.jpg'
bound_point_num = 250
bound = get_boundary(img_path, bound_point_num)

cw = get_conformal_welding(bound)

Please also refer to example.ipynb

Dependencies

  • NumPy
  • SciPy
  • Matplotlib
  • Opencv

Contributing

Contributions are welcome via pull requests.

Code Author

  • Chenran Lin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hbs-1.0.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hbs-1.0.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file hbs-1.0.0.tar.gz.

File metadata

  • Download URL: hbs-1.0.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for hbs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 737ec9e45799a0c8feb5c61a7eb9feccf30f6edb54ebc764b2cc7d55a090d1ea
MD5 a565a76391fec4aa577fcc6d420eebf0
BLAKE2b-256 88e63bc2467401117313532ee64612aa19281c0bd109ac88726753e1ce71aa64

See more details on using hashes here.

File details

Details for the file hbs-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hbs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for hbs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9069457e0488bc12cfdf78a2ab0436b0e583567ccf0fae5d7ab767972808b22d
MD5 8fded3f16e26e084c0434ebbfb5fcbd3
BLAKE2b-256 28a6f48955a80c5d30028d5c8442f6f3b84aa1b2d660e4b931023928113a9bfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page