Skip to main content

Structure Tensor Scale Space for Python

2D and 3D structure tensor scale space implementation for Python.

Forked from and based on Niels Jeppesen's structure tensor repository. Contains its basic functionality, with extra support of structure tensor scale space and expansion to a ring filter instead of the integrating filter.

For theoretical details see: Paper, ArXiv

In-depth examples, as well as reproduced figures from the publication can be found and interactively tested in the associated Code Ocean capsule.

Installation

pip install stss

Tiny Examples

The only parameter necessary for this version of structure tensor calculation is $\sigma$ (sigma), which is a scalar.

It is possible to disable the ring filter and use the original structure tensor definition, then another scalar parameter $\rho$ (rho) is necessary.

Single scale for 2D and 3D

The st2ss package supports running either 2D or 3D structure tensor analysis. The appropriate algorithm is chosen based on the dimensionality of the provided array. Eigenvalues (val) are sorted ascending.

import numpy as np
from stss import st

sigma = 1.5

# Load 2D or 3D data (np.array).
image = np.random.random((128, 128))
# image = np.random.random((128, 128, 128))

S, val, vec = st.structure_tensor(image, sigma)

Compared to the original structure tensor repository, for volume with shape (x, y, z) the eigenvectors (vec) are returned in the intuitive order of xyz, not zyx.

Scale Space

Running scale-space calculation requires providing a list of $\sigma$ (sigma) values. Again, it is possible to disable the ring filter. In that case a separate list of $\rho$ (rho) values is necessary.

Scale space method returns an additional parameter scale containing scale value at which the strongest structural response was obtained for each pixel/voxel.

import numpy as np
from stss import st

sigma_list = np.arange(1,6,0.1)

# Load 2D or 3D data (np.array).
image = np.random.random((128, 128))
# image = np.random.random((128, 128, 128))

S, val, vec, scale = st.scale_space(volume, sigma_list)

In-depth examples can be found and interactively tested in the associated Code Ocean capsule.

CUDA support

To accelerate the calculation through CUDA, install CuPy. Then, simply replace imports with from stss import st_cupy as st, and proceed as usual.

CUDA support is in its early version. Some issues may arise.

Contributions

Contributions are welcome, just create an issue or a PR.

Reference

If you use this any of this for academic work, please consider citing our work.

Pieta, Pawel Tomasz, et al. Feature-Centered First Order Structure Tensor Scale-Space in 2D and 3D. 2024, [paper]

@article{pieta2025a,
  author={Pieta, Pawel Tomasz and Dahl, Anders Bjorholm and Frisvad, Jeppe Revall and Bigdeli, Siavash Arjomand and Christensen, Anders Nymark},
  journal={IEEE Access}, 
  title={Feature-Centered First Order Structure Tensor Scale-Space in 2D and 3D}, 
  year={2025},
  volume={13},
  pages={9766-9779},
  doi={10.1109/ACCESS.2025.3527227}}

More information

License

MIT License (see LICENSE file).

Metadata

Release files for stss 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stss 0.1.0
File Size Uploaded Provenance Actions
stss-0.1.0.tar.gz 14.6 kB Without provenance Details for stss-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stss 0.1.0
File Interpreter ABI Platform Actions
stss-0.1.0-py3-none-any.whl Python 3 none any Details for stss-0.1.0-py3-none-any.whl

Total release size: 36.7 kB

Release files / stss-0.1.0.tar.gz

Download URL stss-0.1.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f5a554015af0d1305fb5be41297c99f84414d444cd655587b31c9670c63e9350
BLAKE2b-256 checksum
How to use checksums
e1b52f2e79ef6aff815f08f0e6db5dba7bc4d584cc5fb04504ae9ce7d5c496c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / stss-0.1.0-py3-none-any.whl

Download URL stss-0.1.0-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
000eb4215906d112e7d6311f61a8b253f14cf387715ed4408353fea270c9a591
BLAKE2b-256 checksum
How to use checksums
a306e369f6a0e47c81a2c169669836b2525aebd28a59a061c7209708c72a3475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Security for stss 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page