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
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.
Metadata
Release files for srad 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| srad-0.1.1.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| srad-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / srad-0.1.1.tar.gz
| Download URL | srad-0.1.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b5e7fab331a025551798112621d3038aefec55d12fa80d92f1c81a806a1c6db
|
|
BLAKE2b-256 checksum How to use checksums |
4a2c4a0a258ab7530f03d1b29f24de4f5b142f1833887da0cd48f4d0a8f964c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / srad-0.1.1-py3-none-any.whl
| Download URL | srad-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
18bfae24770fcf9dd57bc7af3291401059ab13cf3837ac86691a4842fd21954e
|
|
BLAKE2b-256 checksum How to use checksums |
f56c9632cb29e156069c129bbf77a94ab72e9278c26f33bd19324433a07b07ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|