Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Low-Rank Sparse Noise Decomposition — GoDec

Python implementation of the Greedy Semi-Soft GoDec algorithm (GreBsmo) by Tianyi Zhou and Dacheng Tao, originally published at AISTATS 2013. The algorithm decomposes an image sequence into three components: a low-rank background, a sparse foreground, and a residual noise term. It is well-suited for background subtraction in fluorescence microscopy or any video where the background is slowly varying.

Original MATLAB code: https://tianyizhou.wordpress.com/2014/05/23/aistats-2013-grebsmo-code-is-released/

Input / Output

The function accepts 8-bit or 16-bit TIFF stacks and grayscale or RGB .avi movies (RGB is converted to grayscale). It produces four TIFF stacks in the current directory:

FileContent
1-Original.tifOriginal stack (or grayscale version of the .avi)
2-Background.tifLow-rank component (background)
3-Sparse.tifSparse component (moving objects)
4-Noise.tifResidual noise

Installation

Requires Python ≥ 3.10.

git clone https://github.com/FattaccioliLab/godec
cd godec
pip install .

For a development install with linting and test dependencies:

pip install -e ".[dev]"

Usage

From the command line

python examples/run_example.py data/Escalator-1000f-8b.tif

From Python

fromgodecimportDecomposeGoDec# Default parameters, all framesDecomposeGoDec("path/to/stack.tif")
# Custom parameters, first 500 frames onlyDecomposeGoDec(
"path/to/movie.avi",
rank=3,
power=5,
tau=7,
tol=0.001,
k=2,
dynamicrange=16,
max_frames=500,
)

Parameters

ParameterDefaultDescription
filenamePath to .tif, .tiff, or .avi
rank3Upper bound on rank of the low-rank component
power5Power scheme order (higher → better accuracy, slower)
tau7Soft thresholding value for the sparse component
tol0.001Convergence tolerance (relative residual norm)
k2Rank step size
dynamicrange8Output bit depth (8 or 16)
max_frames0Frames to process (0 = all)

Note: rank, tau, power, tol, and k are algorithm parameters inherited from Zhou & Tao. For most microscopy data, the defaults are a reasonable starting point; tau may need tuning depending on signal intensity.

Sample data

The data/ folder contains two test sequences:

  • Escalator-1000f-8b.tif — first 1000 frames of the CDnet escalator sequence, converted to an 8-bit TIFF stack.
  • Escalator.avi — the original AVI movie.

These files are large and tracked via Git LFS. Run git lfs pull after cloning if they are not present.

For additional benchmark video sequences commonly used in the background subtraction community, see the CDnet 2014 dataset and the Background Models Challenge (BMC).

Running tests

pytest tests/

References

Tianyi Zhou and Dacheng Tao, GoDec: Randomized Low-rank & Sparse Matrix Decomposition in Noisy Case, ICML 2011.

Tianyi Zhou and Dacheng Tao, Greedy Bilateral Sketch, Completion and Smoothing, AISTATS 2013. DOI: 10.5555/3042817.3042875

Python implementation: J. Fattaccioli (Department of Chemistry, ENS) — March 2020.

About

Background subtraction for fluorescence microscopy time-lapses and video sequences via low-rank sparse decomposition (GoDec / GreBsmo, Zhou & Tao 2013).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages