PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
2.04k stars 470 forks source link

Enhancement: Implement methods automatically determining threshold parameter #394

Open jachymb opened 6 years ago

jachymb commented 6 years ago

Mathematica has a range of methods to determine the wavelet thresholding parameter. In pywt, it is the parameter value of the pywt.threshold function. The list of automated methods to determine the parameter in Mathematica can be found here: http://reference.wolfram.com/language/ref/WaveletThreshold.html#DetailsAndOptions It would be nice to see this also in pywt.

grlee77 commented 6 years ago

We have some functionality of this type in scikit-image which is using PyWavelets under the hood.
Specifically, denoise_wavelet performs denoising using either the universal threshold (VisuShrink) or the BayesShrink method.

There is also estimate_sigma which is a standalone function that estimates the standard deviation of images corrupted by Gaussian noise via the median absolute deviation (MAD) method.

Although the functions mentioned above are in an "image" processing library, the implementations are not restricted to 2D and work in general for n-dimensions.

At the moment PyWavelets primarily just provides wavelet transforms, but does not provide implementations for various applications such as denoising, compression, etc. That said, we do have thresholding which is not a transform and is a building block for applications. It might make sense to duplicate the small estimate_sigma function here for users that don't want to install the larger scikit-image package.

We have made plans to update the docs to highlight some applications in downstream libraries as part of the upcoming 1.0 release. I think it also makes sense to point to the scikit-image functions above as an example application in the thresholding docs.

grlee77 commented 6 years ago

The above response is not intended to discourage you if you are interested in contributing functionality along these lines. I think it would be great to have additional options either here or in a downstream package.

micha2718l commented 6 years ago

Hi All, I saw this request and saw an opportunity to jump into contributing with a small feature addition. Been using PyWavelets for a while and would love to help out. I put together a fork which implements the estimate_sigma function as scikit-image has: https://github.com/micha2718l/pywt/tree/threshold_alpha I would be willing to put together a PR and/or write better tests/docs to support, as well as rework the algorithm to better suit PyWavelets as opposed to scikit-image as need be.

Let me know how that sounds, thanks!

rgommers commented 6 years ago

@micha2718l that sounds great, PR very welcome.

For discussion: the name estimate_sigma isn't super descriptive, and I'm not 100% sure that it should live in the main pywt namespace. For the name, perhaps something like estimate_noise or estimate_noiselevel?