Skip to content

add n-dimensional support to denoise_wavelet - #2242

Merged
jni merged 8 commits into
scikit-image:masterfrom
grlee77:wavelet_nd
Aug 13, 2016
Merged

jni merged 8 commits into
scikit-image:masterfrom
grlee77:wavelet_nd

Conversation

@grlee77

@grlee77 grlee77 commented Aug 10, 2016

Copy link
Copy Markdown
Contributor

Description

This adds n-dimensional support to denoise_wavelet. The multichannel handling matches the existing denoise_tv_chambolle which also has n-dimensional support.

@codecov-io

codecov-io commented Aug 10, 2016 •

Copy link
Copy Markdown

Current coverage is 90.68% (diff: 100%)

Merging #2242 into master will increase coverage by 0.02%

@@             master      #2242   diff @@
==========================================
  Files           303        303          
  Lines         21763      21783    +20   
  Methods           0          0          
  Messages          0          0          
  Branches       2012       2012          
==========================================
+ Hits          19731      19755    +24   
+ Misses         1669       1667     -2   
+ Partials        363        361     -2   

Powered by Codecov. Last update e691467...721dd37

@JDWarner

Copy link
Copy Markdown
Contributor

👍 for this approach, and LGTM. This would be how to handle, e.g., several MRI sequences which are inherently independent.

For color, though, we clearly need something a little different. Working on each channel in isolation actually can exacerbate color noise. That's an issue for a different PR, though (discuss in #2240).


def denoise_wavelet(img, sigma=None, wavelet='db1', mode='soft'):
def denoise_wavelet(img, sigma=None, wavelet='db1', mode='soft',
multichannel=False):

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.

In the docstring, please, change expected data type for img to smth like (M[, N[, ..., P]][, C]), and add description for multichannel parameter.

@grlee77

grlee77 commented Aug 11, 2016

Copy link
Copy Markdown
Contributor Author

I plan to update the tests to add a 4D test case.
Also, I still have to make sure any examples using this have the multichannel argument set appropriately.

Parameters
----------
img : ndarray (2D/3D) of ints, uints or floats
img : ndarray ([M[, N[, ...P]][, C]) of ints, uints or floats

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.

Sorry, actually this should be (M, N[, ...P][, C]) if we declare 2+D support. Please, notice that [, ] mark optional dimensions.

@grlee77 grlee77 Aug 12, 2016 •

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 think 1D is already supported here, though?

edit: 1D through 4D operation now verified via new tests

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.

True. Let it be (M[, N[, ...P]][, C]) then.

@soupault

Copy link
Copy Markdown
Member

One last remark, otherwise LGTM.

multichannel=multichannel)
res2 = restoration.denoise_wavelet(noisy, sigma=0.1,
multichannel=multichannel)
assert (res1.sum()**2 <= res2.sum()**2)

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 know this wasn't your approach, but this test seems quite weak to me! How about showing a reduction in the noise after denoise_wavelet, or increase in SNR?

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.

sure. it should be simple to verify at least a rough improvement via compare_psnr

@jni

jni commented Aug 12, 2016

Copy link
Copy Markdown
Member

@grlee77 thank you! This PR makes me very happy. What do you think of my test suggestion? We do have a policy that new PRs shouldn't have to fix old code issues, so feel free to ignore.

@grlee77

grlee77 commented Aug 12, 2016

Copy link
Copy Markdown
Contributor Author

Tests for 1D through 4D inputs were added and PSNR is compared.
The plot_denoise.py example has also been updated.

PSNR only improves slightly with the default sigma (~10%). To get a reasonably denoised image, the user has to specify sigma larger than the true value. This was resolved in #2241, so I will not plan to address that in this PR.

@jni
jni merged commit 99136ab into scikit-image:master Aug 13, 2016
@jni

jni commented Aug 13, 2016

Copy link
Copy Markdown
Member

Brilliant! Thank you, @grlee77!

@grlee77
grlee77 deleted the wavelet_nd branch May 11, 2017 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⏩ type: Enhancement Improve existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants