PyEllipsoid
PyEllipsoid is the package for drawing and analysis of ellipsoids in 3D volumetric images (3D arrays).
Installation
The easiest way to install the latest version is by using pip:
$ pip install pyellipsoid
You may also use Git to clone the repository and install it manually:
$ git clone https://github.com/ashkarin/pyellipsoid.git $ cd pyellipsoid $ python setup.py install
How to use
To draw an ellipsoid:
import numpy as np
from pyellipsoid import drawing
# Define an image shape, axis order is: Z, Y, X
image_shape = (128, 128, 128)
# Define an ellipsoid, axis order is: X, Y, Z
ell_center = (64, 64, 64)
ell_radii = (5, 50, 30)
ell_angles = np.deg2rad([80, 30, 20]) # Order of rotations is X, Y, Z
# Draw a 3D binary image containing the ellipsoid
image = drawing.make_ellipsoid_image(image_shape, ell_center, ell_radii, ell_angles)
To compute inertia ellipsoid for given ellipsoid image:
import numpy as np
from pyellipsoid import drawing, analysis
# Draw a 3D binary image containing an ellipsoid
image_shape = (128, 128, 128)
ell_center = (64, 64, 64)
ell_radii = (5, 50, 30)
ell_angles = np.deg2rad([80, 30, 20])
image = drawing.make_ellipsoid_image(image_shape, ell_center, ell_radii, ell_angles)
# Compute inertia ellipsoid
points = analysis.sample_random_points(image)
inertia_ellipsoid = analysis.compute_inertia_ellipsoid(points)
To rotate axes and find relative rotation between the original and rotated axes:
import numpy as np
from pyellipsoid import geometry
original_axes = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
rot_angles = np.deg2rad([0, 0, 45]) # Rotate around Z-axis by 45 deg
# Build rotation matrix and rotate the axes
rotm = geometry.build_rotation_matrix(*rot_angles)
rotated_axes = np.dot(rotm, np.transpose(original_axes)).T
# Find relative rotation
rel_rotm = geometry.find_relative_axes_rotation(original_axes, rotated_axes)
# Validate relative rotation matrix
rel_rotated_axes = np.dot(rel_rotm, np.transpose(original_axes)).T
assert(np.all(rotated_axes == rel_rotated_axes))
# Compute rotation angles
# Please note, that these angles might differ from rot_angles!
rel_rot_angles = geometry.rotation_matrix_to_angles(rel_rotm)
print(np.rad2deg(rel_rot_angles))
Metadata
Release files for pyellipsoid 0.0.3
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 |
|---|---|---|---|---|
| pyellipsoid-0.0.3.tar.gz | 5.4 kB | Without provenance | Details for pyellipsoid-0.0.3.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyellipsoid-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pyellipsoid-0.0.3-py3-none-any.whl |
| pyellipsoid-0.0.3-py2-none-any.whl | Python 2 | none | any | Details for pyellipsoid-0.0.3-py2-none-any.whl |
Total release size: 19.8 kB
Release files / pyellipsoid-0.0.3.tar.gz
| Download URL | pyellipsoid-0.0.3.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c11df304f5986cc0dc13e473845ad70665a1ed869ed52d7f7187694ec7ebcf2
|
|
BLAKE2b-256 checksum How to use checksums |
aa78ea15c59db68db52ebc52e8abd281e3f7834cffd9a1866f947b12ecfe76f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.4
|
Release files / pyellipsoid-0.0.3-py3-none-any.whl
| Download URL | pyellipsoid-0.0.3-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f68ade20b9c232baf9fa452196204ce8f1d177b465c80faf76ab2e84259f7d9
|
|
BLAKE2b-256 checksum How to use checksums |
2942a8678e9af5cd7b3b966d997ada5c0c9b8997977dd3ba7e87684925958bcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.4
|
Release files / pyellipsoid-0.0.3-py2-none-any.whl
| Download URL | pyellipsoid-0.0.3-py2-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
5e0695aa422347e38eef285b2e2394db659a75332c808556e3b9f02483264f39
|
|
BLAKE2b-256 checksum How to use checksums |
84ae8a3aec0fc4262ad45b2ea474b75b842d655ef47673afb7f7b2ab9556596d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.7.4
|
Security for pyellipsoid 0.0.3
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.