Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add n-dimensional support to denoise_wavelet #2242

Merged
merged 8 commits into from
Aug 13, 2016

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented Aug 10, 2016

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
Copy link

codecov-io commented Aug 10, 2016

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
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).

@@ -394,7 +394,8 @@ def _wavelet_threshold(img, wavelet, threshold=None, sigma=None, mode='soft'):
return pywt.waverecn(denoised_coeffs, wavelet)


def denoise_wavelet(img, sigma=None, wavelet='db1', mode='soft'):
def denoise_wavelet(img, sigma=None, wavelet='db1', mode='soft',
multichannel=False):
Copy link
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
Copy link
Contributor Author

grlee77 commented Aug 11, 2016

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.

@@ -400,7 +400,7 @@ def denoise_wavelet(img, sigma=None, wavelet='db1', mode='soft',

Parameters
----------
img : ndarray (2D/3D) of ints, uints or floats
img : ndarray ([M[, N[, ...P]][, C]) of ints, uints or floats
Copy link
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.

Copy link
Contributor Author

@grlee77 grlee77 Aug 12, 2016

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
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
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
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
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
Copy link
Member

jni commented Aug 12, 2016

@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
Copy link
Contributor Author

grlee77 commented Aug 12, 2016

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
Copy link
Member

jni commented Aug 13, 2016

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.

None yet

5 participants