Skip to content

Commit

Permalink
Fix test and doctest for multichannel kwarg in denoise_bilateral
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkoHunter committed Jan 25, 2016
1 parent 39db97d commit d53ea48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/examples/filters/plot_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
ax[0, 1].imshow(denoise_tv_chambolle(noisy, weight=0.1, multichannel=True))
ax[0, 1].axis('off')
ax[0, 1].set_title('TV')
ax[0, 2].imshow(denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15))
ax[0, 2].imshow(denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15, multichannel=True))
ax[0, 2].axis('off')
ax[0, 2].set_title('Bilateral')

ax[1, 0].imshow(denoise_tv_chambolle(noisy, weight=0.2, multichannel=True))
ax[1, 0].axis('off')
ax[1, 0].set_title('(more) TV')
ax[1, 1].imshow(denoise_bilateral(noisy, sigma_range=0.1, sigma_spatial=15))
ax[1, 1].imshow(denoise_bilateral(noisy, sigma_range=0.1, sigma_spatial=15, multichannel=True))
ax[1, 1].axis('off')
ax[1, 1].set_title('(more) Bilateral')
ax[1, 2].imshow(astro)
Expand Down
11 changes: 5 additions & 6 deletions skimage/restoration/_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
cval : string
Used in conjunction with mode 'constant', the value outside
the image boundaries.
multichannel : bool, default False
multichannel : bool
Whether the last axis of the image is to be interpreted as multiple
channels or another spatial dimension.
Expand All @@ -66,17 +66,16 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
>>> astro = astro[220:300, 220:320]
>>> noisy = astro + 0.6 * astro.std() * np.random.random(astro.shape)
>>> noisy = np.clip(noisy, 0, 1)
>>> denoised = denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15)
>>> denoised = denoise_bilateral(noisy, sigma_range=0.05,
... sigma_spatial=15, multichannel=True)
"""
if multichannel:
if image.shape[2] not in (3, 4):
msg = "Input image must be grayscale, RGB, or RGBA; but has " \
"a shape {0}."
msg = "Input image must be grayscale, RGB, or RGBA; but has shape {0}."
warnings.warn(msg.format(image.shape))
else:
if image.ndim > 2:
msg = "Input image must be grayscale, RGB, or RGBA; but has " \
"a shape {0}."
msg = "Input image must be grayscale, RGB, or RGBA; but has shape {0}."
raise TypeError(msg.format(image.shape))


Expand Down
4 changes: 2 additions & 2 deletions skimage/restoration/tests/test_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def test_denoise_bilateral_3d():
img = np.clip(img, 0, 1)

out1 = restoration.denoise_bilateral(img, sigma_range=0.1,
sigma_spatial=20)
sigma_spatial=20, multichannel=True)
out2 = restoration.denoise_bilateral(img, sigma_range=0.2,
sigma_spatial=30)
sigma_spatial=30, multichannel=True)

# make sure noise is reduced in the checkerboard cells
assert img[30:45, 5:15].std() > out1[30:45, 5:15].std()
Expand Down

0 comments on commit d53ea48

Please sign in to comment.