BM3D ORNL
BM3D ORNL removes streak and ring artifacts from neutron-imaging sinograms. BM3D means block-matching and three-dimensional filtering.
The BM3D algorithm was originally proposed by K. Dabov, A. Foi, V. Katkovnik, and K. Egiazarian in the paper "Image Denoising by Sparse 3D Transform-Domain Collaborative Filtering" (2007).
The library provides a Python API backed by Rust. Key features include:
- Streak removal targets vertical detector artifacts.
- Multiscale processing handles streaks wider than one scale can capture.
- Fourier-SVD combines frequency detection with rank-one matrix decomposition.
- Stack processing batches three-dimensional sinogram data.
- Rust processing accelerates block matching and transforms.
Documentation
Full documentation: https://bm3dornl.readthedocs.io
It covers the installation guide, a tutorial, the parameter reference, the GUI guide, and the API reference.
How to install
Use pip for published releases and Pixi for a clone.
Do not run pip install -e . in a clone. It is unsupported: Pixi pins every
dependency in pixi.lock, and pip resolves its own set. pixi run build
compiles the Rust extension and installs the package in editable mode.
The [gui] extra installs the separate bm3dornl-gui binary wheel from PyPI.
It does not build the GUI in a clone. Run the clone's GUI with pixi run gui.
Using Pip (released packages)
# Core library only
pip install bm3dornl
# With GUI application
pip install bm3dornl[gui]
Supported Platforms
| Platform | Architecture | Library | GUI |
|---|---|---|---|
| Linux | x86_64 | ✅ | ✅ |
| macOS | ARM64 (Apple Silicon) | ✅ | ✅ |
Usage
from bm3dornl import bm3d_ring_artifact_removal
import numpy as np
# Load sinogram data - 2D (H, W) or 3D stack (N, H, W)
sinogram = np.load("sinogram.npy")
# Standard BM3D denoising (generic white noise)
denoised = bm3d_ring_artifact_removal(sinogram, mode="generic", sigma_random=0.1)
# Streak artifact removal (recommended for ring artifacts)
denoised = bm3d_ring_artifact_removal(sinogram, mode="streak", sigma_random=0.1)
# With custom parameters (all parameters are flat, no dict wrapping)
denoised = bm3d_ring_artifact_removal(
sinogram,
mode="streak",
sigma_random=0.1,
patch_size=8, # Patch size (7 or 8 recommended)
step_size=4, # Step size for patch extraction
search_window=40, # Max search distance
max_matches=64, # Similar patches per 3D group
batch_size=32, # Batch size for stack processing
)
# Multi-scale BM3D for wide streaks (v0.7.0+)
denoised = bm3d_ring_artifact_removal(
sinogram,
mode="streak",
multiscale=True, # Enable multi-scale pyramid processing
num_scales=None, # Auto-detect (or set explicitly)
filter_strength=1.0, # Filtering intensity multiplier
)
Fourier-SVD Method (v0.7.0+)
For an alternative streak-removal method:
from bm3dornl.fourier_svd import fourier_svd_removal
# Fourier-guided streak removal
denoised = fourier_svd_removal(
sinogram,
fft_alpha=1.0, # Weight for detected vertical-frequency energy
notch_width=2.0, # Gaussian notch width in frequency bins
)
Performance
Processing time for one 720×725 sinogram, mean of 100 runs (measured 2026-08-31 and 2026-09-02):
| Method | Linux x86_64, 24-core Threadripper | Apple M2 Max laptop |
|---|---|---|
| bm3dornl, streak mode | 0.094 s | 0.20 s |
| bm3dornl, Fourier-SVD | 0.017 s | 0.022 s |
| bm3d-streak-removal (reference, x86_64 only) | 31.8 s | not available |
The Rust backend runs in parallel across cores with Rayon. The benchmark study
behind these numbers, including the TomoPy comparison, lives on the
feature/joss-paper branch under study/. A smaller comparison notebook is
notebooks/evaluation_performance.ipynb.
Key optimizations:
- Integral image pre-screening for fast block matching
- Early termination in distance calculations
- Pre-computed FFT plans
- Fast Walsh-Hadamard transform for 8×8 patches
Development
Use Pixi for every command in a clone. See How to install
for the install policy. Pixi supplies Python, Maturin, HDF5, and the other
build dependencies. It does not supply Rust: install a stable Rust toolchain
with rustup first, so that cargo is on your PATH.
| Task | Command |
|---|---|
| Create the environment without running a task (optional) | pixi install |
| Build the Rust extension | pixi run build |
| Run all tests (Rust and Python) | pixi run test |
| Lint (rustfmt and clippy) | pixi run lint |
| Run the clone's GUI | pixi run gui (release build) or pixi run gui-debug |
| Run the benchmarks | pixi run bench |
Clone the repository, enter its directory, then run pixi run build,
pixi run test, and pixi run gui, in that order.
# Prerequisites: Pixi and a stable Rust toolchain (rustup)
git clone https://github.com/ornlneutronimaging/bm3dornl.git
cd bm3dornl
pixi run build
pixi run test
pixi run gui
Each pixi run command installs the environment on demand. Run pixi install
first only when you want to create the environment separately.
The first pixi run gui compiles the GUI application, which takes a few
minutes; later runs start immediately.
Optional: test-data submodule
tests/bm3dornl-data is a Git submodule with notebook reference data. It is
not required to build the package or run tests. The clone command above is
enough for pixi run build and pixi run test.
Fetch it only if you want to run the notebooks:
git submodule update --init tests/bm3dornl-data
git -C tests/bm3dornl-data lfs pull
The submodule is hosted on code.ornl.gov. It clones anonymously over HTTPS,
without an ORNL account or SSH key. The tomostack_small.h5 file is about
1.4 GB. It uses Git Large File Storage (Git LFS). Without Git LFS, the file
remains a small text pointer. The lfs pull step can take time.
GUI Application
BM3DORNL includes a standalone GUI application for interactive ring artifact removal.
Installation
Released binaries (Linux x86_64 and macOS Apple Silicon):
pip install bm3dornl[gui]
Or install the GUI separately:
pip install bm3dornl-gui
In a clone, run the GUI through Pixi. See How to install.
pixi run gui
Launching
The released binary installs a bm3dornl-gui command:
bm3dornl-gui
Features
- Load HDF5 files with tree browser for dataset selection
- Interactive slice viewer with histogram
- Side-by-side comparison of original and processed images
- Adjust parameters before processing
- View the processed result after processing finishes
- ROI selection for histogram (Shift+drag to select region)
- Export processed data to TIFF or HDF5
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
| Shift+Drag | Select ROI for histogram |
| Scroll | Zoom in/out on image |
| Drag | Pan image |
Parameter Reference
| Parameter | Default | Description |
|---|---|---|
mode |
"streak" |
"generic" for white noise, "streak" for ring artifacts |
sigma_random |
0.1 |
Noise standard deviation |
patch_size |
8 |
Patch size (7 or 8 recommended) |
step_size |
4 |
Step size for patch extraction |
search_window |
24 |
Maximum search distance for similar patches |
max_matches |
16 |
Maximum similar patches per 3D group |
batch_size |
32 |
Batch size for stack processing |
streak_sigma_smooth |
3.0 |
Smoothing for streak mode (streak mode only) |
multiscale |
False |
Enable multi-scale processing for wide streaks |
num_scales |
None |
Number of scales (None selects it automatically) |
filter_strength |
1.0 |
Filtering strength multiplier for multi-scale |
debin_iterations |
30 |
Cubic-spline expansion iterations for multiscale corrections |
Fourier-SVD Parameters
| Parameter | Default | Description |
|---|---|---|
fft_alpha |
1.0 |
Weight for detected vertical-frequency energy |
notch_width |
2.0 |
Gaussian notch width in frequency bins |
Contributing and Support
- Contributing: see CONTRIBUTING.md for setup, coding standards, testing, and pull requests. Participation follows our Code of Conduct.
- Reporting issues: open an issue at https://github.com/ornlneutronimaging/bm3dornl/issues. Please include your platform, the bm3dornl version, and a minimal reproduction.
- Getting support: for usage questions, start a GitHub Discussion or email the maintainer at zhangc@ornl.gov.
Metadata
Release files for bm3dornl 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bm3dornl-0.11.0.tar.gz | 144.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| bm3dornl-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.17+ x86-64 | Details |
| bm3dornl-0.11.0-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details |
| bm3dornl-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.17+ x86-64 | Details |
| bm3dornl-0.11.0-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| bm3dornl-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details |
| bm3dornl-0.11.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 7.2 MB
Release files / bm3dornl-0.11.0.tar.gz
| Download URL | bm3dornl-0.11.0.tar.gz |
|---|---|
| Size | 144.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ec805d16f28cdeb50081918df946a5f46baf277f64d0281f590969a7b7a9513
|
|
BLAKE2b-256 checksum How to use checksums |
55f30abc07e38875b135fc787900152d470e6b5a6af1840bd99ce29cd681ab86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | bm3dornl-0.11.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
9df7c89a8373bbe959392c69bc78b2b9bdee1c71c24e23bb186183c050b3765c
|
|
BLAKE2b-256 checksum How to use checksums |
9132dea9ff8d14cf645985234bedace067ea3c6448e40730b9a6bab8aa5088d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | bm3dornl-0.11.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 934.3 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b2fcf4b6c8e4afe6398e2bbefd91a26600a9cc4cf0fe8cd59d721cb19ffd94d8
|
|
BLAKE2b-256 checksum How to use checksums |
9fbaefbf70efd322670220fe93e34bc06f7f8eb34c128a3b035d903c75a126c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | bm3dornl-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
92d07765c5a70067c973bfcbb7f86b0b31c8a5f47c870b421855d59199e01d06
|
|
BLAKE2b-256 checksum How to use checksums |
a52c591df7b9ab2dadf5a3b49f8d47a31e20ca2bcaa1a79b7d0d055caf221b3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | bm3dornl-0.11.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 934.1 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
461bd82f4358c200c24403c47a14c8e79a1e6b0f77324e981492ad2cedc3c11b
|
|
BLAKE2b-256 checksum How to use checksums |
37909d726894cefb14575d689b575a1932eb0a017acf95bd590b10cc93c802ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | bm3dornl-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d3bc48380a1405373b01350fc91a5d8af2d1a4c6e351f2bcf7784266c2e8815d
|
|
BLAKE2b-256 checksum How to use checksums |
a78bfc5931007886c11f5551bf55c14a800dd56d0a0f3fdb03bdfae41496c853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency logRelease files / bm3dornl-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | bm3dornl-0.11.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 934.3 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7a0f0f929b226aa2f4f62cfb4a227ed707eb0dbaafb5b76c704583a32b174343
|
|
BLAKE2b-256 checksum How to use checksums |
70cabd90dbafa286c1c5bb0da9d01a29974fa9a253b024c7321cf7f45a52ade2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 3, 2026.
Transparency log