BM3D for streak artifact removal in neutron imaging
Project description
BM3D ORNL
A high-performance BM3D denoising library for neutron imaging, optimized for streak/ring artifact removal from sinograms.
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).
BM3D ORNL provides a Python API with a Rust backend for efficient, parallel processing of tomography data. Key features:
- Streak/Ring Artifact Removal: Specialized mode for removing vertical streak artifacts common in neutron and X-ray imaging
- Multi-Scale Processing: True multi-scale BM3D for handling wide streaks that single-scale cannot capture (based on Mäkinen et al. 2021)
- Fourier-SVD Method: Alternative fast algorithm (~2.6x faster than BM3D) combining FFT-based energy detection with rank-1 SVD
- Stack Processing: Efficient batched processing of 3D sinogram stacks
- High Performance: Rust backend with optimized block matching (integral images, early termination) and transforms (Hadamard, FFT)
How to install
Using Pip
# 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) | ✅ | ✅ |
Using Pixi (Development)
pixi install
pixi run build
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 faster processing with excellent results on many datasets:
from bm3dornl.fourier_svd import fourier_svd_removal
# Fast streak removal (~2.6x faster than BM3D)
denoised = fourier_svd_removal(
sinogram,
fft_alpha=1.0, # FFT-guided trust factor (0.0 disables FFT guidance)
notch_width=2.0, # Gaussian notch filter width
)
Performance
The Rust backend provides high performance for tomography stacks:
| Metric | Value |
|---|---|
| Speed | ~0.63s per frame (512×512) on Apple Silicon |
| Memory | >50% reduction via chunked processing |
| Parallelism | Zero-overhead parallel processing via Rayon |
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
We use pixi for development environment management.
- Clone repo.
- Run
pixi run buildto compile the Rust backend and install in editable mode. - Run
pixi run testto run tests. - Run
pixi run benchto run performance benchmarks.
git clone https://github.com/ornlneutronimaging/bm3dornl.git
cd bm3dornl
pixi run build
pixi run test
GUI Application
BM3DORNL includes a standalone GUI application for interactive ring artifact removal.
Installation
pip install bm3dornl[gui]
Or install the GUI separately:
pip install bm3dornl-gui
Launching
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
- Real-time parameter adjustment
- 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 |
3 |
Step size for patch extraction |
search_window |
39 |
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 |
1.0 |
Smoothing for streak mode (streak mode only) |
multiscale |
False |
Enable multi-scale processing for wide streaks |
num_scales |
None |
Number of scales (auto-detected if None) |
filter_strength |
1.0 |
Filtering strength multiplier for multi-scale |
debin_iterations |
30 |
Debinning iterations for multi-scale |
Fourier-SVD Parameters
| Parameter | Default | Description |
|---|---|---|
fft_alpha |
1.0 |
FFT-guided trust factor (0.0 disables FFT guidance) |
notch_width |
2.0 |
Gaussian notch filter width in frequency domain |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 bm3dornl-0.9.0.tar.gz.
File metadata
- Download URL: bm3dornl-0.9.0.tar.gz
- Upload date:
- Size: 126.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e19f705100a4c733796e8d511b51c40a6a207344ee3a6c06f3904f533ba9d553
|
|
| MD5 |
22f93f17f846597554860bdbfda1d089
|
|
| BLAKE2b-256 |
3b3dff551872a536791cf34f00c0503f2d7855452987066bce782e7c592a9be4
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0.tar.gz:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0.tar.gz -
Subject digest:
e19f705100a4c733796e8d511b51c40a6a207344ee3a6c06f3904f533ba9d553 - Sigstore transparency entry: 1031751399
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c10fed8209f6d660d5685489ef0b5d238067c963228cfdceab02bb06085130ba
|
|
| MD5 |
40b2ffbfadc55157200510313d6c771d
|
|
| BLAKE2b-256 |
47f8c13cacbb89d1c40fef5a769a5bdfdad865e24700cf84448ad0205aeed3a0
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
c10fed8209f6d660d5685489ef0b5d238067c963228cfdceab02bb06085130ba - Sigstore transparency entry: 1031751511
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 932.0 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5a931dec0b839c56614550efbf8a33d4d4965b3f8dba4573f69f113af4f5570
|
|
| MD5 |
26a92dabaa625f46fcde3d961074e42f
|
|
| BLAKE2b-256 |
507d1c6824661d8bb924c35f61ecb86179f039a84a2a5ce001633ce8ec1bb75c
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
b5a931dec0b839c56614550efbf8a33d4d4965b3f8dba4573f69f113af4f5570 - Sigstore transparency entry: 1031751727
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ccfe819e66e25e29dbcb4663707e33a91f71957182eb8d9c445a01ba290f16
|
|
| MD5 |
5ceb0ae2ebe5141a6dd7c9d3fd679f30
|
|
| BLAKE2b-256 |
6e54f8b112fb3efd2feb535640d5eb72471057a23e46f15d03c8ea59d4ff7f49
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d3ccfe819e66e25e29dbcb4663707e33a91f71957182eb8d9c445a01ba290f16 - Sigstore transparency entry: 1031751618
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 932.2 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55bf9d032419d8c923dc1e8a67e2249cbbfecc6ca2ee1f57e356981bf7d86080
|
|
| MD5 |
efd9e6bdd35d37416ef2777d9a9326fe
|
|
| BLAKE2b-256 |
4344145c31d98868b6db5f170ecf436cdcf3102b828115b700088f19af45d655
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
55bf9d032419d8c923dc1e8a67e2249cbbfecc6ca2ee1f57e356981bf7d86080 - Sigstore transparency entry: 1031751669
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
613acbe829bbc6edc30f47cc3e2dc657c2dd8eb50388aa28e1475db407aae5a4
|
|
| MD5 |
1790d979d74f61a6ce6c1ea795d9e017
|
|
| BLAKE2b-256 |
1f361c594ad26bc5632933427d2c66fd851290a54f75ba5b64a0217f8cac5f13
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
613acbe829bbc6edc30f47cc3e2dc657c2dd8eb50388aa28e1475db407aae5a4 - Sigstore transparency entry: 1031751453
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bm3dornl-0.9.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: bm3dornl-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 932.2 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b050a7940f5cb0f83493249d0edf2e57516b982d925585b96d92ee2ecf011e48
|
|
| MD5 |
0d7c3f243a51aa1536c46fdc518ec6af
|
|
| BLAKE2b-256 |
59e3c484d2b481079cb471db1dbf45a8a57c507e22a880d9f4465718f0737048
|
Provenance
The following attestation bundles were made for bm3dornl-0.9.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on ornlneutronimaging/bm3dornl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bm3dornl-0.9.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
b050a7940f5cb0f83493249d0edf2e57516b982d925585b96d92ee2ecf011e48 - Sigstore transparency entry: 1031751562
- Sigstore integration time:
-
Permalink:
ornlneutronimaging/bm3dornl@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/ornlneutronimaging
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f70451503dfef383bffa5a3d5f3e2d33a223cde8 -
Trigger Event:
push
-
Statement type: