本文簡要介紹 python 語言中 scipy.ndimage.gaussian_filter1d
的用法。
用法:
scipy.ndimage.gaussian_filter1d(input, sigma, axis=-1, order=0, output=None, mode='reflect', cval=0.0, truncate=4.0, *, radius=None)#
一維高斯濾波器。
- input: array_like
輸入數組。
- sigma: 標量
高斯核的標準差
- axis: 整數,可選
要計算的輸入軸。默認值為 -1。
- order: 整數,可選
0 階對應於具有高斯核的卷積。正階對應於具有高斯導數的卷積。
- output: 數組或數據類型,可選
放置輸出的數組,或返回數組的 dtype。默認情況下,將創建一個與輸入具有相同 dtype 的數組。
- mode: {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’},可選
mode 參數確定輸入數組如何擴展到其邊界之外。默認為‘reflect’。每個有效值的行為如下:
- ‘reflect’ (d c b a | a b c d | d c b a)
通過反射最後一個像素的邊來擴展輸入。此模式有時也稱為half-sample 對稱模式。
- ‘constant’ (k k k k | a b c d |呸呸呸呸)
通過使用 cval 參數定義的相同常量值填充邊之外的所有值來擴展輸入。
- ‘nearest’ (啊啊啊啊| a b c d |嘀嘀嘀嘀)
通過複製最後一個像素來擴展輸入。
- ‘mirror’ (d c b | a b c d | c b a)
通過反射最後一個像素的中心來擴展輸入。此模式有時也稱為whole-sample 對稱模式。
- ‘wrap’ (a b c d | a b c d | A B C D)
通過環繞到相對邊來擴展輸入。
為了與插值函數保持一致,還可以使用以下模式名稱:
- ‘grid-mirror’
這是‘reflect’ 的同義詞。
- ‘grid-constant’
這是‘constant’ 的同義詞。
- ‘grid-wrap’
這是‘wrap’ 的同義詞。
- cval: 標量,可選
如果模式為‘constant’,則填充過去輸入邊的值。默認值為 0.0。
- truncate: 浮點數,可選
在這麽多標準偏差處截斷過濾器。默認值為 4.0。
- radius: 無或整數,可選
高斯核的半徑。如果指定,內核的大小將為
2*radius + 1
, 和截短被忽略。默認為“無”。
- gaussian_filter1d: ndarray
參數 ::
返回 ::
注意:
高斯核的大小
2*radius + 1
沿著每個軸。如果半徑是 None,默認值radius = round(truncate * sigma)
將會被使用。例子:
>>> from scipy.ndimage import gaussian_filter1d >>> import numpy as np >>> gaussian_filter1d([1.0, 2.0, 3.0, 4.0, 5.0], 1) array([ 1.42704095, 2.06782203, 3. , 3.93217797, 4.57295905]) >>> gaussian_filter1d([1.0, 2.0, 3.0, 4.0, 5.0], 4) array([ 2.91948343, 2.95023502, 3. , 3.04976498, 3.08051657]) >>> import matplotlib.pyplot as plt >>> rng = np.random.default_rng() >>> x = rng.standard_normal(101).cumsum() >>> y3 = gaussian_filter1d(x, 3) >>> y6 = gaussian_filter1d(x, 6) >>> plt.plot(x, 'k', label='original data') >>> plt.plot(y3, '--', label='filtered, sigma=3') >>> plt.plot(y6, ':', label='filtered, sigma=6') >>> plt.legend() >>> plt.grid() >>> plt.show()
相關用法
- Python SciPy ndimage.gaussian_filter用法及代碼示例
- Python SciPy ndimage.gaussian_laplace用法及代碼示例
- Python SciPy ndimage.gaussian_gradient_magnitude用法及代碼示例
- Python SciPy ndimage.generic_laplace用法及代碼示例
- Python SciPy ndimage.generate_binary_structure用法及代碼示例
- Python SciPy ndimage.grey_erosion用法及代碼示例
- Python SciPy ndimage.generic_filter1d用法及代碼示例
- Python SciPy ndimage.generic_gradient_magnitude用法及代碼示例
- Python SciPy ndimage.generic_filter用法及代碼示例
- Python SciPy ndimage.grey_closing用法及代碼示例
- Python SciPy ndimage.grey_opening用法及代碼示例
- Python SciPy ndimage.geometric_transform用法及代碼示例
- Python SciPy ndimage.grey_dilation用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy ndimage.variance用法及代碼示例
- Python SciPy ndimage.correlate1d用法及代碼示例
- Python SciPy ndimage.binary_dilation用法及代碼示例
- Python SciPy ndimage.distance_transform_bf用法及代碼示例
- Python SciPy ndimage.find_objects用法及代碼示例
- Python SciPy ndimage.label用法及代碼示例
- Python SciPy ndimage.maximum_filter1d用法及代碼示例
- Python SciPy ndimage.iterate_structure用法及代碼示例
- Python SciPy ndimage.map_coordinates()用法及代碼示例
- Python SciPy ndimage.binary_opening用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.ndimage.gaussian_filter1d。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。