image-rs / imageproc

Image processing operations
MIT License
759 stars 150 forks source link

Add non-local-means image denoising #16

Open theotherphil opened 9 years ago

theotherphil commented 9 years ago

A naive implementation would be extremely slow, so we should probably implement something like this: http://www.gipsa-lab.grenoble-inp.fr/~laurent.condat/publis/condat_resreport_NLmeansv3.pdf.

csheaff commented 3 years ago

The link above is broken unfortunately. After taking a look at implementations in both OpenCV and skimage, both use a method based on patches weighted by similarity. However, the skimage implementation incorporates an input parameter called patch_distance which limits the search for patches to a distance from the pixel in question - an option that could save considerable time I imagine. There is also a sigma input parameter that can help with robustness when determining patch similarity.

Moreover, skimage provides an optimized version of the aforementioned approach found here and it is used by default. The relevant publication is:

Froment, Jacques. "Parameter-free fast pixelwise non-local means denoising." Image Processing On Line 4 (2014): 300-326.

and it demonstrates qualitatively similar filtering performance while reducing computation time substantially. Here is the discussion leading to its selection.

Here's a skimage demo of the slow vs fast. You can see that the fast version with sigma PSNR is quite close to the slow version with sigma. I inserted timing statements to compare runtime, and the fast version is faster by an order of magnitude.

I'm inclined to pursue the fast version with sigma unless any counter arguments are made, which would be welcome.

theotherphil commented 3 years ago

Either option sounds good - we can always add a fast/accurate toggle at a later date if there's a need.