Speckle Reducing Anisotropic Diffusion - Python implementation
Project description
SRAD - Speckle Reducing Anisotropic Diffusion
A Python implementation of the Speckle Reducing Anisotropic Diffusion (SRAD) algorithm for denoising images affected by speckle noise, commonly found in ultrasound, SAR (Synthetic Aperture Radar), and other coherent imaging systems.
๐ About
This package is a Python port of the original MATLAB implementation by Xingorno. The SRAD algorithm is based on anisotropic diffusion, which smooths homogeneous regions while preserving edges โ making it ideal for speckle reduction without blurring important structures.
How It Works
SRAD extends the classic Perona-Malik anisotropic diffusion by incorporating a speckle-sensitive diffusion coefficient. The algorithm iteratively applies a diffusion process where:
- Homogeneous regions (high speckle) โ Strong smoothing
- Edge regions (low speckle, high gradient) โ Preserved
The mathematical model follows:
$$\frac{\partial I}{\partial t} = \text{div}[c(q) \nabla I]$$
Where $c(q)$ is the diffusion coefficient computed from the instantaneous coefficient of variation $q$.
๐ Installation
From PyPI (coming soon)
pip install srad
From Source
git clone https://github.com/Keno-00/Speckle-Reducing-Anisotropic-Diffusion-SRAD.git
cd Speckle-Reducing-Anisotropic-Diffusion-SRAD
pip install .
๐ป Usage
As a Library
import cv2
import srad
# Load your grayscale image
img = cv2.imread('path/to/image.png', cv2.IMREAD_GRAYSCALE)
# SRAD Parameters
iteration_max = 200 # Number of diffusion iterations
time_step = 0.05 # Time step per iteration (stability: keep โค 0.25)
decay_factor = 1 # Controls how fast edges are "locked in"
# Apply SRAD denoising
denoised = srad.SRAD(img, iteration_max, time_step, decay_factor)
# Save result
cv2.imwrite('denoised.png', denoised)
Command Line
Run the built-in example on noisyImage.png:
python -m srad
โ๏ธ Parameters
| Parameter | Type | Description | Recommended |
|---|---|---|---|
iterationMaxStep |
int | Maximum number of diffusion iterations | 100-300 |
timeSize |
float | Time step size (affects stability and speed) | 0.05-0.15 |
decayFactor |
float | Exponential decay for the diffusion coefficient | 1.0 |
Tips:
- Higher
iterationMaxStepโ More smoothing, longer runtime - Larger
timeSizeโ Faster convergence, but may become unstable if > 0.25 - Higher
decayFactorโ Edges lock in faster
๐ Repository Structure
.
โโโ srad/ # Python package
โ โโโ __init__.py # SRAD algorithm implementation
โ โโโ __main__.py # CLI entry point
โโโ SpeckleReducingAD.m # Original MATLAB implementation (general)
โโโ SpeckleReducingAD_New.m # Original MATLAB implementation (optimized)
โโโ testSRAD.m # MATLAB test script
โโโ noisyImage.png # Example input image
โโโ denoised.png # Example output image
โโโ setup.py # Package configuration
โโโ pyproject.toml # Build system configuration
โโโ LICENSE # MIT License
โโโ README.md # This file
๐ References
This implementation is based on the following papers:
-
Yu, Y., & Acton, S. T. (2002). Speckle reducing anisotropic diffusion. IEEE Transactions on Image Processing, 11(11), 1260-1270.
๐ IEEE Xplore -
Perona, P., & Malik, J. (1990). Scale-space and edge detection using anisotropic diffusion. IEEE Transactions on Pattern Analysis and Machine Intelligence, 12(7), 629-639.
๐ IEEE Xplore
๐ Acknowledgments
- Original MATLAB Implementation: Xingorno
- Python Port: Keno S. Jose (this contribution)
- Initial Python Contribution: namioj
This project is a fork of the original repository, ported to Python for easier integration into image processing pipelines.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
The original MATLAB implementation by Xingorno is also under the MIT License.
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 Distribution
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 srad-0.1.0.tar.gz.
File metadata
- Download URL: srad-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19994481379a3a5beea24ae4da14de49e0913b7becf18a8b3d5564a72642e491
|
|
| MD5 |
a05614023e5b4b9cc24b221ec9ac3945
|
|
| BLAKE2b-256 |
6bbb861213bbf9a25aa18eed67e7b571a28f99acf9828ef3c22f6db6ce41ef47
|
File details
Details for the file srad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: srad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99ea379026f1922560e0244a00560385c121404d6cfff59007dc6e760e4d6b5c
|
|
| MD5 |
27971a378ff264033e1f4b208c7dd8e8
|
|
| BLAKE2b-256 |
80f38793cf51305d7e3f15cbb9b2c6b9bb6f43f7440ff608450deb328a367cf3
|