def _smooth(image, sigma, mode, cval):
"""Return image with each channel smoothed by the Gaussian filter."""
smoothed = np.empty(image.shape, dtype=np.double)
# apply Gaussian filter to all dimensions independently
if image.ndim == 3:
for dim in range(image.shape[2]):
ndi.gaussian_filter(image[..., dim], sigma,
output=smoothed[..., dim],
mode=mode, cval=cval)
else:
ndi.gaussian_filter(image, sigma, output=smoothed,
mode=mode, cval=cval)
return smoothed
评论列表
文章目录