Skip to main content

VSNR algorithm for image destripping

Project description

pyvsnr

Description

This repository contains the sources of the 2D-CPU/GPU based denoising code of the VSNR algorithm.

Installation

$ pip install pyvsnr

Requirements

For CPU execution, the vsnr algorithm requires only the numpy package, with matplotlib and tifffile packages for examples and tests running.

For GPU execution, the cupy library is required. Follow the installaton instructions for more details.

  • numpy
  • cupy (for GPU execution, optional)
  • matplotlib
  • tifffile

Usage

For a single image processing :

from pyvsnr import VSNR
from skimage import io

# read the image to correct
img = io.imread('my_image.tif')

# vsnr object creation
vsnr = VSNR(img.shape)

# add filter (at least one !)
vsnr.add_filter(alpha=1e-2, name='gabor', sigma=(1, 30), theta=20)
vsnr.add_filter(alpha=5e-2, name='gabor', sigma=(3, 40), theta=20)

# vsnr initialization
vsnr.initialize()

# image processing
img_corr = vsnr.eval(img, maxit=100, cvg_threshold=1e-4)
...

Some applicative examples are given in examples.py.

stripes removal example :

$ python
>>> from pyvsnr.examples import ex_camera 
>>> ex_camera('stripes') 

curtains removal example :

$ python
>>> from pyvsnr.examples import ex_camera 
>>> ex_camera('curtains') 

curtains removal example on real image (FIB-SEM) :

$ python
>>> from pyvsnr.examples import ex_fib_sem 
>>> ex_fib_sem() 

Note 1 : in case of images batchs, in particularly in the case of stacks where successive images are quite similar (FIB-SEM slices for instance), computation time can be significantly decreased by this way :

import glob
from pyvsnr import VSNR
from skimage import io

fnames = sorted(glob.glob('my_directory/*.tif'))
img0 = io.imread(fnames[0])
vsnr = VSNR(img0.shape) # assuming all the images have the same size !!!
vsnr.add_filter(alpha=1e-2, name='gabor', sigma=(1, 30), theta=20)
vsnr.add_filter(alpha=5e-2, name='gabor', sigma=(3, 40), theta=20)
vsnr.initialize()

# images processing
for fname in fnames:
    img = io.imread(fname)
    img_corr = vsnr.eval(img, maxit=100, cvg_threshold=1e-4)
    ...

Note 2 : in case of GPU executions, the first run is always more longer than the other ones. Keep it in mind when evaluating your processing time.

Running times evolution :

 $ python
>>> from pyvsnr.examples import ex_perf_evaluation 
>>> ex_perf_evaluation() 

Developers information

Before pushing your developments, check the unitests run correctly.

$ python -m unittest pyvsnr.tests
VSN will run on CPU ...                                                
CPU/GPU running time : 4.296875                                        
.VSN will run on CPU ...                                               
CPU/GPU running time : 4.203125                                        
.                                                                      
---------------------------------------------------------------------- 
Ran 2 tests in 8.512s                                                  
                                                                       
OK                                                                     

Authors information

This is a port to python of the original Matlab code developed by Jerome FEHRENBACH and Pierre WEISS.

All credit goes to the original author.

In case you use the results of this code with your article, please don't forget to cite:

  • Fehrenbach, Jérôme, Pierre Weiss, and Corinne Lorenzo. "Variational algorithms to remove stationary noise: applications to microscopy imaging." IEEE Transactions on Image Processing 21.10 (2012): 4420-4430.
  • Fehrenbach, Jérôme, and Pierre Weiss. "Processing stationary noise: model and parameter selection in variational methods." SIAM Journal on Imaging Sciences 7.2 (2014): 613-640.
  • *Escande, Paul, Pierre Weiss, and Wenxing Zhang. "A variational model for multiplicative structured noise removal." Journal of Mathematical Imaging and Vision 57.1 (2017): 43-55.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvsnr-1.0.0.tar.gz (7.4 MB view details)

Uploaded Source

Built Distribution

pyvsnr-1.0.0-py3-none-any.whl (14.8 MB view details)

Uploaded Python 3

File details

Details for the file pyvsnr-1.0.0.tar.gz.

File metadata

  • Download URL: pyvsnr-1.0.0.tar.gz
  • Upload date:
  • Size: 7.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7

File hashes

Hashes for pyvsnr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 70a2390db122a924cfbaea58fb3f7a61dd6268dbe3495dbd79244d55d656a252
MD5 72cddf67afd4db3ac8630ca8b79fb505
BLAKE2b-256 c990e4ecf54913f633ccbb0a14a37b3c4d8ac7b827bfd13e833d61749aa7cfdd

See more details on using hashes here.

File details

Details for the file pyvsnr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyvsnr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7

File hashes

Hashes for pyvsnr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20890c6f60c09818235bc8fc3b27da96119af95353a0a6bb7c07227ec9f57f30
MD5 cabdb982e22fefe23272a2911b600dc1
BLAKE2b-256 7ef6b950a9fcccb207eb6d220489c4258dc2c4ed2340c04d76f505691aa20378

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page