Least Squares fitting of ellipses, python routine
based on the publication Halir, R., Flusser, J.: 'Numerically Stable Direct Least Squares Fitting of Ellipses'
Install
pip install lsq-ellipse
https://pypi.org/project/lsq-ellipse/
Example execution
import numpy as np
from ellipse import LsqEllipse
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
if __name__ == '__main__':
# avalible in the `example.py` script in this repo
X1, X2 = example.make_test_ellipse()
X = np.array(list(zip(X1, X2)))
reg = LsqEllipse().fit(X)
center, width, height, phi = reg.as_parameters()
print(f'center: {center[0]:.3f}, {center[1]:.3f}')
print(f'width: {width:.3f}')
print(f'height: {height:.3f}')
print(f'phi: {phi:.3f}')
fig = plt.figure(figsize=(6, 6))
ax = plt.subplot()
ax.axis('equal')
ax.plot(X1, X2, 'ro', zorder=1)
ellipse = Ellipse(
xy=center, width=2*width, height=2*height, angle=np.rad2deg(phi),
edgecolor='b', fc='None', lw=2, label='Fit', zorder=2
)
ax.add_patch(ellipse)
plt.xlabel('$X_1$')
plt.ylabel('$X_2$')
plt.legend()
plt.show()
Cite this work
@software{ben_hammel_2020_3723294,
author = {Ben Hammel and Nick Sullivan-Molina},
title = {bdhammel/least-squares-ellipse-fitting: v2.0.0},
month = mar,
year = 2020,
publisher = {Zenodo},
version = {v2.0.0},
doi = {10.5281/zenodo.3723294},
url = {https://doi.org/10.5281/zenodo.3723294}
}
Ben Hammel, & Nick Sullivan-Molina. (2020, March 21). bdhammel/least-squares-ellipse-fitting: v2.0.0 (Version v2.0.0). Zenodo. http://doi.org/10.5281/zenodo.3723294
Metadata
Release files for lsq-ellipse 2.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lsq-ellipse-2.2.1.tar.gz | 5.6 kB | Without provenance | Details for lsq-ellipse-2.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lsq_ellipse-2.2.1-py3-none-any.whl | Python 3 | none | any | Details for lsq_ellipse-2.2.1-py3-none-any.whl |
Total release size: 11.3 kB
Release files / lsq-ellipse-2.2.1.tar.gz
| Download URL | lsq-ellipse-2.2.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a40860d1af348f9e71491cb1f5cd2b9ef99f22e54fc98e7fa801caf459bda7ba
|
|
BLAKE2b-256 checksum How to use checksums |
0a4815f788d84729d68de91d5c7ecc5511b964beccb00c723f981e1841a9e1a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / lsq_ellipse-2.2.1-py3-none-any.whl
| Download URL | lsq_ellipse-2.2.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d8588b353914530ba6e6645610d06f73d20650b3ed6565acc66a652cf7db008
|
|
BLAKE2b-256 checksum How to use checksums |
47c82a441f1ad6e96a5bf1e8285fa93bf5a482d533241de6965b102f6c9ad7c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for lsq-ellipse 2.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.