scipy.ndimage.
convolve1d#
- scipy.ndimage.convolve1d(input, weights, axis=-1, output=None, mode='reflect', cval=0.0, origin=0)[source]#
沿著給定軸計算一維卷積。
沿著給定軸的陣列線會與給定的權重進行卷積。
- 參數:
- inputarray_like
輸入陣列。
- weightsndarray
一維數字序列。
- axisint, optional
要沿著計算的 input 軸。預設值為 -1。
- outputarray 或 dtype, optional
要放入輸出的陣列,或返回陣列的 dtype。預設情況下,將會建立與輸入相同 dtype 的陣列。
- 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])