mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-06 13:30:21 +08:00
Remove useless multichannel=True kwarg from tests
This commit is contained in:
@@ -49,16 +49,14 @@ ax[0, 0].set_title('noisy')
|
||||
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,
|
||||
multichannel=True))
|
||||
ax[0, 2].imshow(denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15))
|
||||
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,
|
||||
multichannel=True))
|
||||
ax[1, 1].imshow(denoise_bilateral(noisy, sigma_range=0.1, sigma_spatial=15))
|
||||
ax[1, 1].axis('off')
|
||||
ax[1, 1].set_title('(more) Bilateral')
|
||||
ax[1, 2].imshow(astro)
|
||||
|
||||
@@ -66,14 +66,21 @@ 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, multichannel=True)
|
||||
>>> denoised = denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15)
|
||||
"""
|
||||
if multichannel:
|
||||
if image.ndim != 3:
|
||||
raise ValueError("Use ``multichannel=False`` for 2D grayscale images. "
|
||||
"The last axis of the input image must be multiple "
|
||||
"color channels not another spatial dimension.")
|
||||
if image.ndim == 2:
|
||||
raise ValueError("Use ``multichannel=False`` for 2D grayscale "
|
||||
"images. The last axis of the input image "
|
||||
"must be multiple color channels not another "
|
||||
"spatial dimension.")
|
||||
else:
|
||||
raise ValueError("Bilateral filter is only implemented for "
|
||||
"2D grayscale images (image.ndim == 2) and "
|
||||
"2D multichannel (image.ndim == 3) images, "
|
||||
"but the input image has {0} dimensions. "
|
||||
"".format(image.ndim))
|
||||
elif image.shape[2] not in (3, 4):
|
||||
if image.shape[2] > 4:
|
||||
warnings.warn("The last axis of the input image is interpreted "
|
||||
@@ -86,11 +93,11 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
|
||||
warnings.warn(msg.format(image.shape))
|
||||
else:
|
||||
if image.ndim > 2:
|
||||
raise TypeError("Bilateral filter is not implemented for "
|
||||
"grayscale images of 3 or more dimensions, "
|
||||
"but input image has {0} dimension. Use "
|
||||
"``multichannel=True`` for 2-D RGB "
|
||||
"images.".format(image.shape))
|
||||
raise ValueError("Bilateral filter is not implemented for "
|
||||
"grayscale images of 3 or more dimensions, "
|
||||
"but input image has {0} dimension. Use "
|
||||
"``multichannel=True`` for 2-D RGB "
|
||||
"images.".format(image.shape))
|
||||
|
||||
|
||||
mode = _mode_deprecations(mode)
|
||||
|
||||
@@ -175,10 +175,8 @@ def test_denoise_bilateral_color():
|
||||
img += 0.5 * img.std() * np.random.rand(*img.shape)
|
||||
img = np.clip(img, 0, 1)
|
||||
|
||||
out1 = restoration.denoise_bilateral(img, sigma_range=0.1,
|
||||
sigma_spatial=20, multichannel=True)
|
||||
out2 = restoration.denoise_bilateral(img, sigma_range=0.2,
|
||||
sigma_spatial=30, multichannel=True)
|
||||
out1 = restoration.denoise_bilateral(img, sigma_range=0.1, sigma_spatial=20)
|
||||
out2 = restoration.denoise_bilateral(img, sigma_range=0.2, sigma_spatial=30)
|
||||
|
||||
# make sure noise is reduced in the checkerboard cells
|
||||
assert img[30:45, 5:15].std() > out1[30:45, 5:15].std()
|
||||
@@ -187,14 +185,14 @@ def test_denoise_bilateral_color():
|
||||
|
||||
def test_denoise_bilateral_3d_grayscale():
|
||||
img = np.ones((50, 50, 3))
|
||||
assert_raises(TypeError, restoration.denoise_bilateral, img, \
|
||||
assert_raises(ValueError, restoration.denoise_bilateral, img,
|
||||
multichannel=False)
|
||||
|
||||
|
||||
def test_denoise_bilateral_3d_multichannel():
|
||||
img = np.ones((50, 50, 50))
|
||||
with expected_warnings(["grayscale"]):
|
||||
result = restoration.denoise_bilateral(img, multichannel=True)
|
||||
result = restoration.denoise_bilateral(img)
|
||||
|
||||
expected = np.empty_like(img)
|
||||
expected.fill(np.nan)
|
||||
@@ -204,6 +202,7 @@ def test_denoise_bilateral_3d_multichannel():
|
||||
|
||||
def test_denoise_bilateral_multidimensional():
|
||||
img = np.ones((10, 10, 10, 10))
|
||||
assert_raises(ValueError, restoration.denoise_bilateral, img)
|
||||
assert_raises(ValueError, restoration.denoise_bilateral, img,
|
||||
multichannel=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user