replace separate 2D and 3D Chambolle TV denoising functions with a single nD function#1839
replace separate 2D and 3D Chambolle TV denoising functions with a single nD function#1839jni merged 11 commits intoscikit-image:masterfrom
Conversation
|
Also, the default |
skimage/restoration/_denoise.py
Outdated
There was a problem hiding this comment.
use helper function _add_shifted_p_to_d for more clarity? The code is a bit hard to read here...
|
Regarding the default value of |
|
I will take a look at the performance. Regarding the |
|
Go for it for |
|
@emmanuelle Just using order='F' for I also verified that resulting denoised image is indeed identical to the existing implementation. I will make a small separate PR for the |
skimage/restoration/_denoise.py
Outdated
There was a problem hiding this comment.
here you're adding a C-order and an F-order arrays, which is not optimal.
|
@grlee77 thanks for checking the performance issue. Creating F-order instead of C-order arrays was a quick and dirty trick that worked, but in fact it would be better if you could have the first dimension corresponding to the dimension of length ndim, and keep C-order arrays. Do you think it would be possible? Then you would also recover the 2-3% that correspond I think to the moment where you add |
|
Also, you'll need to rebase on master since your PR on weight has been merged. |
|
okay sure. I will take a look in a few days |
|
Agreed with @emmanuelle about |
|
@grlee77 any update on your PR? We shouldn't let this momentum fizzle out :-) ! |
|
Yes, I did make some additional commits, but I think they are still on my laptop. I may be able to push them later today. |
skimage/restoration/_denoise.py
Outdated
There was a problem hiding this comment.
Can you use p.sum(axis=-1)? It is more readable to people unfamiliar with numpy. I would even suggest np.sum(p, axis=-1).
|
@grlee77 I'm late to this party but thank you for an awesome contribution! The code looks cleaner in nd than specialised for 2D, as is often the case, and we get the added benefit of nd compatibility! |
_denoise_tv_chambolle_2d and _denoise_tv_chambolle_3d are replaced by _denoise_tv_chambolle_nd The restriction to 2D and 3D in denoies_tv_chambolle was removed.
…formance regression
…gardless of the number of dimensions. As in the original reference, the stepsize should be in both the numerator and denominator of p.
…2*ndim) use the default weight in all the tests as well.
b24ff7a to
e6a1a19
Compare
|
@emmanuelle |
|
Is there not a way to set a slightly less strict criterion for Coveralls? -0.007% |
|
I opened an issue about that on Coveralls several months ago, but no response... |
skimage/restoration/_denoise.py
Outdated
There was a problem hiding this comment.
shape[-1], surely? Might want to add a test for this after fixing!
There was a problem hiding this comment.
good catch! can't believe I missed that one... I added 3D + channels to one of the tests
There was a problem hiding this comment.
|
@grlee77 Sweet, thank you! =D |
replace separate 2D and 3D Chambolle TV denoising functions with a single nD function
|
Good work! |
|
@stefanv the Guardian of the Dimensions is happy. =P |


This is a refactor of the existing Chambolle TV denoising algorithm, replacing the separate 2D and 3D implementations with a single nD equivalent. The output should be identical to the previous implementation for the 2D and 3D cases.
I debated leaving the 2D code in place because it is a bit simpler to read, but ended up removing it because it was redundant.
A 1D example that would not have run previously: