def _smooth_3d(volume, sigma, mode, cval):
"""Return volume with each channel smoothed by the Gaussian filter."""
smoothed = np.empty(volume.shape, dtype=np.double)
# apply Gaussian filter to all dimensions independently
# volume.ndim == 4 means the volume is multimodal
if volume.ndim == 4:
# compute 3d convolution for each modality, dim is a modality
for dim in range(volume.shape[3]):
ndi.gaussian_filter(volume[..., dim], sigma,
output=smoothed[..., dim],
mode=mode, cval=cval)
else:
ndi.gaussian_filter(volume, sigma, output=smoothed, mode=mode, cval=cval)
return smoothed
评论列表
文章目录