mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-17 11:32:45 +08:00
Raise warning for 3D images in denoise_bilateral
This commit is contained in:
@@ -3,10 +3,11 @@ import numpy as np
|
||||
from .. import img_as_float
|
||||
from ..restoration._denoise_cy import _denoise_bilateral, _denoise_tv_bregman
|
||||
from .._shared.utils import _mode_deprecations
|
||||
import warnings
|
||||
|
||||
|
||||
def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
|
||||
bins=10000, mode='constant', cval=0):
|
||||
bins=10000, mode='constant', cval=0, multichannel=False):
|
||||
"""Denoise image using bilateral filter.
|
||||
|
||||
This is an edge-preserving and noise reducing denoising filter. It averages
|
||||
@@ -45,6 +46,9 @@ 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
|
||||
Whether the last axis of the image is to be interpreted as multiple
|
||||
channels or another spatial dimension.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -64,6 +68,18 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
|
||||
>>> noisy = np.clip(noisy, 0, 1)
|
||||
>>> denoised = denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15)
|
||||
"""
|
||||
if multichannel:
|
||||
if image.shape[2] not in (3, 4):
|
||||
msg = "Input image must be grayscale, RGB, or RGBA; but has " \
|
||||
"a 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}."
|
||||
raise TypeError(msg.format(image.shape))
|
||||
|
||||
|
||||
mode = _mode_deprecations(mode)
|
||||
return _denoise_bilateral(image, win_size, sigma_range, sigma_spatial,
|
||||
bins, mode, cval)
|
||||
|
||||
Reference in New Issue
Block a user