Skip to main content

torchskradon

LICENSE Python PyPI CI Coverage DOI

About

torchskradon mimics the implementation of radon and iradon from scikit-image. All transforms work with batched multi-channel data and are fully differentiable. This allows backpropagation through torchskradon functions to train neural networks or solve optimization problems with torch.optim (see examples).

Installation

pip install torchskradon

Basic Usage

import torch
from skimage.data import shepp_logan_phantom
from skimage.transform import rescale
from torchskradon.functional import skradon, skiradon

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

image = shepp_logan_phantom()
image = rescale(image, scale=0.4, mode='reflect', channel_axis=None)
image = torch.from_numpy(image).unsqueeze(0).unsqueeze(0).to(device)
theta = torch.linspace(0.0, 180.0, max(image.size()[2:])+1)[:-1].to(device)
sinogram = skradon(image, theta=theta)
reconstruction_fbp = skiradon(sinogram, theta=theta, filter_name='ramp')

Examples

For more detailed examples and use cases, see the examples directory:

Accuracy on MNIST

----------------------- Absolute Error of Inverse Radon Transform on MNIST test dataset: 2 tests -----------------------
Name                             Min           Max          Mean        StdDev        Median           IQR      Outliers
------------------------------------------------------------------------------------------------------------------------
torchskradon (CPU)        0.0000e+00    2.2054e-06    3.1475e-07    2.1740e-07    2.5937e-07    2.6217e-07 2159268;272232
torchskradon (GPU)        0.0000e+00    1.9670e-06    1.4094e-07    1.2985e-07    1.0803e-07    1.2759e-07 1415341;427665
------------------------------------------------------------------------------------------------------------------------

--------------------------- Absolute Error of Radon Transform on MNIST test dataset: 2 tests ---------------------------
Name                             Min           Max          Mean        StdDev        Median           IQR      Outliers
------------------------------------------------------------------------------------------------------------------------
torchskradon (CPU)        0.0000e+00    6.2466e-05    1.0514e-06    1.9718e-06    0.0000e+00    1.4305e-06 7713886;6355122
torchskradon (GPU)        0.0000e+00    6.1989e-05    1.0435e-06    1.9558e-06    0.0000e+00    1.4305e-06 7633118;6271687
------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.

Performance on MNIST

--------------------------------------------------------- benchmark 'Inverse Radon Transform on MNIST test dataset': 3 tests --------------------------------------------------------
Name (time in s)           Min                Max               Mean            StdDev             Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
skimage (CPU)          16.8473 (157.73)   16.8693 (130.60)   16.8537 (150.81)   0.0091 (1.06)     16.8511 (155.21)   0.0096 (4.75)          1;0  0.0593 (0.01)          5           1
torchskradon (CPU)      4.8955 (45.83)     5.2628 (40.75)     4.9870 (44.63)    0.1554 (18.10)     4.9192 (45.31)    0.1215 (59.92)         1;1  0.2005 (0.02)          5           1
torchskradon (GPU)      0.1068 (1.0)       0.1292 (1.0)       0.1118 (1.0)      0.0086 (1.0)       0.1086 (1.0)      0.0020 (1.0)           1;1  8.9483 (1.0)           6           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------- benchmark 'Radon Transform on MNIST test dataset': 3 tests ------------------------------------------------------------
Name (time in s)           Min                Max               Mean            StdDev             Median               IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
skimage (CPU)          36.6816 (78.12)    37.3837 (78.01)    36.8518 (77.68)    0.2996 (79.20)    36.7269 (77.48)    0.2385 (41.00)         1;1  0.0271 (0.01)          5           1
torchskradon (CPU)     10.4956 (22.35)    10.6328 (22.19)    10.5554 (22.25)    0.0532 (14.07)    10.5572 (22.27)    0.0763 (13.12)         2;0  0.0947 (0.04)          5           1
torchskradon (GPU)      0.4695 (1.0)       0.4792 (1.0)       0.4744 (1.0)      0.0038 (1.0)       0.4740 (1.0)      0.0058 (1.0)           2;0  2.1080 (1.0)           5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

You can run benchmarks yourself by running:

  python -m pytest --benchmark-only --benchmark-sort="name"

Other Packages

For users interested in more flexible implementations of projection transforms check out:

  1. ASTRA Toolbox

  2. torch-radon

Acknowledgements

This package is inspired by implementations of the Radon transform and its' inverse in skimage.transform, which are based on [1-3].

References

  1. JK Romberg, "Image Projections and the Radon Transform"

  2. AC Kak, M Slaney, “Principles of Computerized Tomographic Imaging”, IEEE Press 1988.

  3. B.R. Ramesh, N. Srinivasa, K. Rajgopal, “An Algorithm for Computing the Discrete Radon Transform With Some Applications”, Proceedings of the Fourth IEEE Region 10 International Conference, TENCON ‘89, 1989

Metadata

Release files for torchskradon 0.1.4

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

Source distribution (sdist)

Source distribution for torchskradon 0.1.4
File Size Uploaded
torchskradon-0.1.4.tar.gz 17.2 kB Details

Built distribution (wheel)

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

Total release size: 28.0 kB

Release files / torchskradon-0.1.4.tar.gz

Download URL torchskradon-0.1.4.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6b2bacf8a5cf7e02d0cd61928129f2954c266614019295eb8c84d3ef05896947
BLAKE2b-256 checksum
How to use checksums
2fb808c6a8ec1fb15a3ad09ec7411d7e8a04d93aea29162752c229b0d37bcaef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release files / torchskradon-0.1.4-py3-none-any.whl

Download URL torchskradon-0.1.4-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d791003afbbc2f8295a46f9b1157e1c632ea55c2c74ab1d3160319759909a251
BLAKE2b-256 checksum
How to use checksums
e388990ae005892dea979a78ac4619825da7c5a864470b89178b21bbbd1e0b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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