Angular projections of 2/3D image objects and subsequent spherical harmonics analysis
Project description
Spherical Texture Extraction
This toolkit extracts Spherical Textures: Angular projections of 2D or 3D image objects with subsequent spherical harmonics analysis.
Installing
Installing can best be done through conda with
conda install sphericaltexture
or to create a dedicated environment:
conda create -n sphericaltexture_env sphericaltexture
alternatively, one can also install through pip with
pip install SphericalTexture
Usage
Construct a SphericalTextureGenerator object, with the dimensionality of the data and the desired spherical projections and output types.
This stg.process_image() takes an image and binary mask, and returns a dictionary with numpy arrays for each projection and output type.
from sphericaltexture import SphericalTextureGenerator
# all outputs:
stg = SphericalTextureGenerator(
ndim=3,
projections=['Shape','Intensity'],
output_types=["Spectrum", "Condensed Spectrum", "Polarization Direction", "Full Projection", "Complex Decomposition"]
)
results = stg.process_image(imgdata, mask)
# only 20-value Intensity spectrum:
stg = SphericalTextureGenerator()
results = stg.process_image(imgdata, mask)
Rays are projected from the center of a rescaled object to capture all angles to make a spherical or circular projection. The values are saved according to the selected projections.
Implemented projections:
- Intensity
- Takes the average intensity along each ray
- Shape
- Takes the distance from the center to the edge of the mask
Subsequently, these are analyzed and saved according to the selected output type.
Implemented output types:
- Spectrum
- 1D power spectrum of the Fourier/Spherical Harmonics decomposition of the spherical/circular projection.
- Condensed Spectrum
- a 20-value version of the
Spectrumbinned along a log2 axis by integration.
- a 20-value version of the
- Polarization Direction
- location in rad of the highest value in the projection
- Full Projection
- The entire circular or spherical projection
- Complex Decomposition
- The Fourier/Spherical Harmonics decomposition of the spherical/circular projection.
Rescaling
Objects are rescaled to the size of the scale parameter in the creation of the SphericalTextureGenerator. This is by default 80: every object processed will be scaled to 80x80x80 pixels before projection to a sphere/circle. Lower values give more speed, higher gives more resolution. However, for many applications in biology, going much higher than 80 seems anecdotally to give diminishing returns.
Speed
The first time you run this with a new shape or ndim parameter a new projection map needs to be constructed. This is afterwards cached in a local folder, and should then subsequently be fast.
Spherical Texture generation is optimized for parallel processing, such as this example:
from concurrent import futures
import numpy as np
from sphericaltexture import SphericalTextureGenerator
# 100 test images of 34x35x36 pixels
your_images = [np.random.randint(1,1e6, size=(34,35,36)) for i in range(100)]
your_masks = [np.ones((34,35,36)) for i in range(100)]
stg = SphericalTextureGenerator(
projections=['Intensity'],
output_types=["Spectrum"]
)
with futures.ThreadPoolExecutor(max_workers=10) as executor:
jobs = [executor.submit(stg.process_image, imgdata, mask) for imgdata, mask in zip(your_images, your_masks)]
all_results = [fut.result() for fut in futures.as_completed(jobs)]
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphericaltexture-0.0.2.tar.gz.
File metadata
- Download URL: sphericaltexture-0.0.2.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8c34abffbc72b051d927d5ff52528760b22109e494e6620a71d839a9cf33309
|
|
| MD5 |
45ea14f644d788a1ca8e2497274a887c
|
|
| BLAKE2b-256 |
ed3250aa48a9ed133d87d37793da8343dfd5777d2fcbe80e41410a39dfae0c87
|
File details
Details for the file sphericaltexture-0.0.2-py3-none-any.whl.
File metadata
- Download URL: sphericaltexture-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a901e51969e2a8db1197fd93101f9465ddd70db67f512f0cf8b704346539771
|
|
| MD5 |
ba970fd94e2c2d0436d386390b68e912
|
|
| BLAKE2b-256 |
58d6346a8e76b4c49ad8dad90ab8e716af2bcd251cb43e21466285b5d4baa0d1
|