scipy.ndimage.
convolve1d#
- scipy.ndimage.convolve1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)[源]#
沿给定轴计算一维卷积。
沿给定轴的数组行与给定权重进行卷积。
- 参数:
- inputarray_like
输入数组。
- weightsndarray
一维数字序列。
- axisint, optional
沿 input 计算的轴。默认为 -1。
- outputarray or dtype, optional
存放输出的数组,或返回数组的数据类型。默认情况下,将创建一个与输入具有相同数据类型的数组。
- mode{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
参数 mode 决定了输入数组如何在其边界之外进行扩展。默认为 'reflect'。每个有效值的行为如下:
- ‘reflect’ (d c b a | a b c d | d c b a)
通过围绕最后一个像素的边缘进行反射来扩展输入。此模式有时也称为半样本对称。
- ‘constant’ (k k k k | a b c d | k k k k)
通过用相同的常量值填充边缘之外的所有值来扩展输入,该常量值由 cval 参数定义。
- ‘nearest’ (a a a a | a b c d | d d d d)
通过复制最后一个像素来扩展输入。
- ‘mirror’ (d c b | a b c d | c b a)
通过围绕最后一个像素的中心进行反射来扩展输入。此模式有时也称为全样本对称。
- ‘wrap’ (a b c d | a b c d | a b c d)
通过环绕到对边来扩展输入。
为了与插值函数保持一致,也可以使用以下模式名称:
- ‘grid-mirror’
这是 ‘reflect’ 的同义词。
- ‘grid-constant’
这是 ‘constant’ 的同义词。
- ‘grid-wrap’
这是 ‘wrap’ 的同义词。
- cvalscalar, optional
如果 mode 为 ‘constant’,用于填充输入边缘之外的值。默认为 0.0。
- originint, optional
控制滤波器在输入数组像素上的放置。值为 0(默认值)时,滤波器居中于像素,正值将滤波器向左移动,负值向右移动。
- 返回:
- convolve1dndarray
与输入具有相同形状的卷积数组
示例
>>> from scipy.ndimage import convolve1d >>> convolve1d([2, 8, 0, 4, 1, 9, 9, 0], weights=[1, 3]) array([14, 24, 4, 13, 12, 36, 27, 0])