Skip to main content

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

Project description

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).

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

stss-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

stss-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file stss-0.1.0.tar.gz.

File metadata

  • Download URL: stss-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for stss-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f5a554015af0d1305fb5be41297c99f84414d444cd655587b31c9670c63e9350
MD5 e804325afa03fca39d3feca2f1081bc9
BLAKE2b-256 e1b52f2e79ef6aff815f08f0e6db5dba7bc4d584cc5fb04504ae9ce7d5c496c2

See more details on using hashes here.

File details

Details for the file stss-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stss-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for stss-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 000eb4215906d112e7d6311f61a8b253f14cf387715ed4408353fea270c9a591
MD5 f5c8abb1440b82ae6426d54872a37c76
BLAKE2b-256 a306e369f6a0e47c81a2c169669836b2525aebd28a59a061c7209708c72a3475

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