Skip to content

roflmaostc/DeconvOptim.jl

Repository files navigation

DeconvOptim.jl



A package for microscopy image based deconvolution via Optim.jl. This package works with N dimensional Point Spread Functions and images. The package was created with microscopy in mind but since the code base is quite general it is possible to deconvolve different kernels as well.

Deconvolution of a dataset with size 512x256x128 took 2.2 seconds on a RTX 3060 GPU!

Documentation Build Status Code Coverage Publication
DOI

Installation

Type ]in the REPL to get to the package manager:

julia> ] add DeconvOptim

Documentation

The documentation of the latest release is here. The documentation of current master is here. For a quick introduction you can also watch the presentation at the JuliaCon 2021.

Usage

A quick example is shown below.

using DeconvOptim, TestImages, Colors, ImageIO, Noise, ImageShow

# load test image
img = Float32.(testimage("resolution_test_512"))

# generate simple Point Spread Function of aperture radius 30
psf = Float32.(generate_psf(size(img), 30))

# create a blurred, noisy version of that image
img_b = conv(img, psf)
img_n = poisson(img_b, 300)

# deconvolve 2D with default options
@time res, o = deconvolution(img_n, psf)

# deconvolve 2D with no regularizer
@time res_no_reg, o = deconvolution(img_n, psf, regularizer=nothing)

# show final results next to original and blurred version
Gray.([img img_n res])

Results Quick Example

Examples

Have a quick look into the examples folder. We demonstrate the effect of different regularizers. There is also a CUDA example. Using regularizers together with a CUDA GPU is faster but unfortunately only a factor of ~5-10. For 3D the speed-up is larger.

CUDA

For CUDA we only provide a Total variation regularizer via TV_cuda. The reason is that Tullio.jl is currently not very fast with CuArrays and especially the derivative of such functions.

Performance Tips

Regularizers

The regularizers are generated with metaprogramming when TV() (or any other regularizer) is called. To prevent that the code compile every time again, define the regularizer once and use it multiple times without newly defining it:

reg = TV()

And in the new cell then use:

res, o = deconvolution(img_n, psf, regularizer=reg)

Development

Feel free to file an issue regarding problems, suggestions or improvement ideas for this package! We would be happy to deconvolve real data! File an issue if we can help deconvolving an image/stack. We would be also excited to adapt DeconvOptim.jl to your special needs!

Citation

If you use this paper, please cite it. Thes PDF is linked here.

@article{Wechsler2023,
  doi = {10.21105/jcon.00099},
  url = {https://doi.org/10.21105/jcon.00099},
  year = {2023},
  publisher = {The Open Journal},
  volume = {1},
  number = {1},
  pages = {99},
  author = {Felix Wechsler and Rainer Heintzmann},
  title = {DeconvOptim.jl - Signal Deconvolution with Julia},
  journal = {Proceedings of the JuliaCon Conferences}
}

Contributions

I would like to thank Rainer Heintzmann for the great support and discussions during development. Furthermore without Tullio.jl and @mcabbott this package wouldn't be as fast as it is. His package and ideas are the basis for the implementations of the regularizers.

Related Packages

  • ThreeDeconv: works great, CPU performance is much slower, GPU performance is slower
  • Deconvolution.jl: rather simple package with Wiener and Lucy Richardson deconvolution.
  • PointSpreadFunctions.jl: generates point spread functions for microscopy applications