Skip to content

NEslahi/pyACT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyACT

pyACT is a Python implementation of adaptive curvelet thresholding (ACT) for denoising images corrupted by additive stationary Gaussian noise, including both white and colored noise models.

The repository includes:

For the original MATLAB reference implementation, see NEslahi/ACT.

Installation

Install the project in editable mode:

python3 -m pip install -e .

Current runtime dependencies:

  • numpy
  • scipy
  • pillow
  • matplotlib

Repository Layout

pyACT/
├── src/
│   ├── __init__.py
│   ├── curvelet.py
│   └── denoising.py
├── test_images/
│   └── *.tif
├── tests/
│   ├── demo.py
│   └── utils.py
├── LICENSE
├── pyproject.toml
└── README.md

Core API

The main denoising entry point is act_filter:

import numpy as np
from PIL import Image

from denoising import act_filter

image = np.asarray(Image.open("test_images/Barbara256.tif"), dtype=np.float64) / 255.0
rng = np.random.default_rng(0)
noise_std = 0.02
noisy = image + noise_std * rng.standard_normal(image.shape)
denoised = act_filter(noisy, noise_var=noise_std**2, threshold_setting="s")

act_filter arguments

  • noisy_img: 2-D noisy image array
  • noise_var: optional scalar variance for white Gaussian noise, or a 2-D FFT power spectral density array for colored noise
  • threshold_setting: thresholding mode, one of "s", "h", or "ksigma"

If noise_var is omitted, the method estimates the noise level internally from the highest-frequency curvelet subband.

Additional public functions exported by the package are:

  • adaptive_curvelet_thresholding
  • compute_dcut_root_psd
  • ml_estimator
  • fdct_wrapping
  • ifdct_wrapping

Demo

Run the demo script with:

python3 tests/demo.py --seed 0 --save-figure --save-to-mat

What the demo does:

  • Selects a bundled test image, or uses --image if provided
  • Synthesizes stationary white or colored Gaussian noise
  • Runs both ksigma thresholding and ACT soft-thresholding
  • Reports PSNR values in the terminal
  • Saves .png and optional .mat outputs to tests/results (created automatically if needed)

Useful CLI options:

  • --image PATH
  • --seed INT
  • --save-figure
  • --output PATH
  • --save-to-mat
  • --mat-output PATH

When default output paths are used, saved filenames include the source image name, the generated kernel type, and the kernel power.

Notes

  • Input images are handled as float64 arrays.
  • Color images loaded by the demo are converted to grayscale before denoising.
  • Colored-noise support is based on supplying the noise FFT-PSD to act_filter.

References

  1. N. Eslahi and A. Aghagolzadeh, "Compressive Sensing Image Restoration Using Adaptive Curvelet Thresholding and Nonlocal Sparse Regularization," IEEE Transactions on Image Processing, vol. 25, no. 7, pp. 3126-3140, 2016. https://doi.org/10.1109/TIP.2016.2562563
  2. E. Candès, L. Demanet, D. Donoho, and X. Ying, "Fast discrete curvelet transforms," Multiscale Modeling and Simulation, vol. 5, no. 3, pp. 861-899, 2006.
  3. J. L. Starck, E. J. Candès, and D. L. Donoho, "The curvelet transform for image denoising," IEEE Transactions on Image Processing, vol. 11, no. 6, pp. 670-684, 2002.

License

See LICENSE for the license distributed with this repository. If you rely on the upstream ACT work or related external sources, review their original licensing terms as well.

Citation:

If you find this code is useful in your research, please consider to cite:

@article{eslahi2016compressive,
title={Compressive sensing image restoration using adaptive curvelet thresholding and nonlocal sparse regularization},
author={Eslahi, Nasser and Aghagolzadeh, Ali},
journal={IEEE Transactions on Image Processing},
volume={25},
number={7},
pages={3126--3140},
year={2016},
publisher={IEEE}
}

Some Examples:

demo_Barbara256_dirac_delta_kernel_power_0 0030 demo_starfish_dirac_delta_kernel_power_0 0028 demo_boats_dirac_delta_kernel_power_0 0025 demo_Monarch256_pink_noise_kernel_power_0 0031 demo_texture_line_pattern_kernel_power_0 1223 demo_texture_2d_Gaussian_kernel_power_0 0786