Skip to content

Commit

Permalink
fix axis bug in multichannel case and add a corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
grlee77 committed Jan 24, 2016
1 parent a30592a commit 53742be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion skimage/restoration/_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def denoise_tv_chambolle(im, weight=0.1, eps=2.e-4, n_iter_max=200,

if multichannel:
out = np.zeros_like(im)
for c in range(im.shape[2]):
for c in range(im.shape[-1]):
out[..., c] = _denoise_tv_chambolle_nd(im[..., c], weight, eps,
n_iter_max)
else:
Expand Down
9 changes: 9 additions & 0 deletions skimage/restoration/tests/test_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ def test_denoise_tv_chambolle_multichannel():
multichannel=True)
assert_equal(denoised[..., 0], denoised0)

# tile astronaut subset to generate 3D+channels data
astro3 = np.tile(astro[:64, :64, np.newaxis, :], [1, 1, 2, 1])
# modify along tiled dimension to give non-zero gradient on 3rd axis
astro3[:, :, 0, :] = 2*astro3[:, :, 0, :]
denoised0 = restoration.denoise_tv_chambolle(astro3[..., 0], weight=0.1)
denoised = restoration.denoise_tv_chambolle(astro3, weight=0.1,
multichannel=True)
assert_equal(denoised[..., 0], denoised0)


def test_denoise_tv_chambolle_float_result_range():
# astronaut image
Expand Down

0 comments on commit 53742be

Please sign in to comment.