Skip to content

Safari77/bm3d_core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bm3d_core

Crates.io Documentation License: MIT

Pure Rust implementation of the BM3D (Block-Matching and 3D filtering) denoising algorithm, optimized for streak/ring artifact removal in tomographic imaging.

Features

  • Generic Float Support: Works with both f32 and f64 precision via the Bm3dFloat trait
  • Streak Artifact Removal: Specialized mode for vertical streak artifacts common in neutron and X-ray imaging
  • Multi-Scale Processing: Pyramid-based processing for wide streaks that single-scale cannot capture
  • Fourier-SVD Method: Fast alternative algorithm combining FFT-based detection with rank-1 SVD
  • High Performance: Parallelized with Rayon, optimized block matching with integral images

Installation

Add this to your Cargo.toml:

[dependencies]
bm3d_core = "0.7"

Quick Start

use bm3d_core::{bm3d_ring_artifact_removal, Bm3dConfig, RingRemovalMode};
use ndarray::Array2;

// Create a noisy 2D image (H x W)
let image: Array2<f32> = /* your image data */;

// Configure BM3D for streak removal
let config = Bm3dConfig {
    mode: RingRemovalMode::Streak,
    sigma_random: 0.1,
    patch_size: 8,
    step_size: 3,
    search_window: 39,
    max_matches: 16,
    ..Default::default()
};

// Run denoising
let denoised = bm3d_ring_artifact_removal(&image, &config);

Main API

High-Level Functions

  • bm3d_ring_artifact_removal - Main entry point for ring/streak artifact removal
  • multiscale_bm3d_streak_removal - Multi-scale processing for wide streaks

Configuration

  • Bm3dConfig - Configuration struct for BM3D parameters
  • RingRemovalMode - Generic (white noise) or Streak (directional artifacts)
  • MultiscaleConfig - Configuration for multi-scale processing

Low-Level Components

  • run_bm3d_kernel - Core BM3D kernel for a single image
  • run_bm3d_step - Single BM3D step (hard/wiener threshold)
  • estimate_noise_sigma - Automatic noise level estimation

Performance

Optimizations include:

  • Integral image pre-screening for fast block matching
  • Early termination in distance calculations
  • Pre-computed FFT plans (Bm3dPlans)
  • Fast Walsh-Hadamard transform for 8×8 patches
  • Zero-overhead parallelism via Rayon

References

  • Dabov, K., Foi, A., Katkovnik, V., & Egiazarian, K. (2007). Image denoising by sparse 3D transform-domain collaborative filtering. IEEE TIP.
  • Mäkinen, Y., et al. (2021). Collaborative Filtering of Correlated Noise: Exact Transform-Domain Variance for Improved Shrinkage and Patch Matching.

License

MIT License - see LICENSE for details.

Related

This crate is part of the bm3dornl project, which also provides:

  • Python bindings via PyO3
  • GUI application for interactive denoising

About

bm3d_core from https://github.com/ornlneutronimaging/bm3dornl — This is used as an operation in my wondermagick fork

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages