Skip to content

Draft: Initial commit of non-local means denoising

Adrian Knagg-Baugh requested to merge nlmdenoise into master

Add non-local means denoising algorithm from OpenCV. Initial commit only provides a command line (command is nlmdenoise), no GUI yet. The command takes one mandatory parameter h_L (strength of luminance denoising) and one optional parameter h_AB (strength of chrominance denoising). If the second parameter is supplied for a mono image it is ignored; if it is not supplied for a colour image it is set to the same as h_L. As chrominance noise can be more off-putting than luminance noise this allows for setting a small luminance denoising parameter and a considerably larger chrominance denoising parameter. The OpenCV function only works with 16-bit data and in practice must be applied to a stretched image. Results from denoising unstretched images are very poor. There is an attempt to detect when it is being applied to an unstretched image and a warning is printed. In the GUI I could possibly add a similar check box to the starnet one to pre-stretch a linear image and unstretch on completion.

This form of noise reduction is very good on Gaussian noise (not so good on salt and pepper noise), but you have to be careful not to overdo it otherwise the image starts to posterise and look cartoonish.

TODO:

  • Add GUI
  • There is a bug with how I'm using fit_replace_buffer() that's causing a crash at the end when restoring an originally-16 bit image to 16 bits.
  • The code does not yet honour com.pref.force_16bit, that can be added once the bug above is fixed as it will use the same code path.

From Monday I'm away for 3 weeks, I'll see what I can get done before I go otherwise I'll finish off once I'm back towards the end of August.

Merge request reports