Skip to content

ENH: Implements wavelet denoising (from #1833) - #2190

Merged
JDWarner merged 12 commits into
scikit-image:masterfrom
stsievert:wavelet-denoise-v2
Aug 5, 2016
Merged

JDWarner merged 12 commits into
scikit-image:masterfrom
stsievert:wavelet-denoise-v2

Conversation

@stsievert

@stsievert stsievert commented Jul 16, 2016 •

Copy link
Copy Markdown
Contributor

Description

This implements wavelet denoising and is based off #1833 -- see that PR for more detail. I tried to git rebase but my attempt failed and this is faster.

New changes that are not reflected in #1833:

  • pywt added to optional requirements
  • a parameter renamed (noise_std --> sigma).

Checklist

[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]

References

This is the same implementation as #1833, but I made a new branch to resolve some merge conflicts (I tried to rebase but sigh).

edit briefly, here's the example in the docstring:

figure_1

Comment thread skimage/restoration/_denoise.py Outdated
return pywt.waverecn([denoised_root, *denoised_detail], wavelet)


def denoise_wavelet(im, sigma=None, wavelet='db1', mode='soft'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer image (or img) instead of im.

@sciunto

sciunto commented Jul 16, 2016

Copy link
Copy Markdown
Member

@stsievert I made a first pass and wrote some comments to give you some indications to improve different things and to pass the tests.

It's good to see wavelets coming in :)

----------
.. [1] Chang, S. Grace, Bin Yu, and Martin Vetterli. "Adaptive wavelet
thresholding for image denoising and compression." Image Processing,
IEEE Transactions on 9.9 (2000): 1532-1546.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add DOI. Format: DOI:xxxyyy

im —> img
adds paper DOI
adds denoise_wavelet __init__
fixes typo in optional_requriments
Comment thread skimage/restoration/_denoise.py Outdated
detail_coeffs = coeffs[-1]['d' * im.ndim]

if sigma is None:
# Estimate the noise std.dev as discussed in PR #1837

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid references to PR as much as possible. Could you summarize the idea please?

Comment thread skimage/restoration/_denoise.py Outdated
by wavelet shrinkage." Biometrika 81.3 (1994): 425-455.
DOI: 10.1093/biomet/81.3.425
"""
import pywt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you import pywt in the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to keep it an optional requirement -- that's what had been decided a couple months ago.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the decision is actually taken. See #1838.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sciunto we have actually reached an agreement on this in #2019 .

@stsievert
stsievert force-pushed the wavelet-denoise-v2 branch from f965224 to dba65b7 Compare July 23, 2016 20:15
@stsievert

Copy link
Copy Markdown
Contributor Author

I've made PyWavelets required. It seems that in #2019 we decided that we would wait for a PR of this flavor to come along.

@stsievert
stsievert force-pushed the wavelet-denoise-v2 branch 2 times, most recently from 40690d1 to eea7dfc Compare July 24, 2016 03:21
@sciunto

sciunto commented Jul 26, 2016

Copy link
Copy Markdown
Member

I'm +1 to do it this way for now and eventually turn off before the release if, for some reasons, we want to wait a little.

@stsievert a little indent issue, then, we should be close :)

@stsievert
stsievert force-pushed the wavelet-denoise-v2 branch 4 times, most recently from 711655a to 622a5aa Compare July 31, 2016 15:34
Comment thread skimage/restoration/_denoise.py Outdated

Parameters
----------
img : ndarray (greater than 2d) of ints, uints or floats

@soupault soupault Aug 4, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>=2D here, but 2D/3D only in the function above.
Could you clarify the supported formats and fix the docstrings accordingly?

@JDWarner

JDWarner commented Aug 4, 2016

Copy link
Copy Markdown
Contributor

I agree with @soupault's comments. Once addressed, this should be good to go.

Scott Sievert added 2 commits August 4, 2016 09:48
as well as DOC: clarify 2D/3D + rewrite notes for denoise_wavelet
Comment thread skimage/restoration/_denoise.py Outdated

img = img_as_float(img)

if img.ndims not in {2, 3}:

@JDWarner JDWarner Aug 4, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

img.ndim here should fix the CI builds.

@stsievert
stsievert force-pushed the wavelet-denoise-v2 branch 2 times, most recently from 355eabf to b09911d Compare August 5, 2016 01:29
TST: removes tests to particular image
@stsievert
stsievert force-pushed the wavelet-denoise-v2 branch from b09911d to 13490a6 Compare August 5, 2016 03:13
@JDWarner

JDWarner commented Aug 5, 2016

Copy link
Copy Markdown
Contributor

Thanks for sticking with this, @stsievert - the AppVeyor issue is unrelated, Travis is happy, and I'm merging.

@JDWarner
JDWarner merged commit 0ea2a34 into scikit-image:master Aug 5, 2016
@soupault soupault mentioned this pull request Aug 5, 2016
8 of 9 tasks
@soupault

soupault commented Aug 6, 2016

Copy link
Copy Markdown
Member

@sciunto

sciunto commented Aug 6, 2016

Copy link
Copy Markdown
Member

+1 and how about grayscale vs color images? Definitely not the same difficulty.

@JDWarner

JDWarner commented Aug 6, 2016

Copy link
Copy Markdown
Contributor

It's actually significantly denoised, but doing the denoising separately per channel is problematic - each gets handled differently, so you end actually adding color noise.

@JDWarner

JDWarner commented Aug 6, 2016

Copy link
Copy Markdown
Contributor

A common approach is to denoise the Y channel in YCbCr space, then return to RGB.

@stsievert

Copy link
Copy Markdown
Contributor Author

Looks like in the top image we specify that the noise variation is less than it actually is. I say change the top image performs as default and the bottom image reduces more noise.

At the very least we should add a note about YCbCr colorspace in the docs, and we should probably show the output when denoising using the YCbCr colorspace.

@sciunto

sciunto commented Aug 8, 2016

Copy link
Copy Markdown
Member

@stsievert Would you like to start a PR on YCbCr? I would be appreciated for the next release :)

@stsievert

Copy link
Copy Markdown
Contributor Author

I am interested in doing that, but am busy for the next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants