scipy.ndimage.
gaussian_laplace#
- scipy.ndimage.gaussian_laplace(input, sigma, output=None, mode='reflect', cval=0.0, *, axes=None, **kwargs)[原始碼]#
使用高斯二階導數的多維拉普拉斯濾波器。
- 參數:
- inputarray_like
輸入陣列。
- sigmascalar 或 scalar 序列
高斯濾波器的標準差,針對每個軸以序列形式給定,或以單一數字形式給定,在這種情況下,所有軸都相等。
- outputarray 或 dtype,選用
放置輸出的陣列,或傳回陣列的 dtype。預設情況下,將建立與輸入相同 dtype 的陣列。
- modestr 或 序列,選用
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-constant’
這是 ‘constant’ 的同義詞。
- ‘grid-mirror’
這是 ‘reflect’ 的同義詞。
- ‘grid-wrap’
這是 ‘wrap’ 的同義詞。
- cvalscalar,選用
如果 mode 為 ‘constant’,則填充輸入邊緣以外的值。預設值為 0.0。
- axesint 或 None 的 tuple
要套用濾波器的軸。如果提供 sigma 或 mode tuple,則其長度必須與軸的數量相符。
- 額外的關鍵字引數將傳遞給 gaussian_filter()。
- 回傳:
- gaussian_laplacendarray
已濾波的陣列。具有與 input 相同的形狀。
範例
>>> from scipy import ndimage, datasets >>> import matplotlib.pyplot as plt >>> ascent = datasets.ascent()
>>> fig = plt.figure() >>> plt.gray() # show the filtered result in grayscale >>> ax1 = fig.add_subplot(121) # left side >>> ax2 = fig.add_subplot(122) # right side
>>> result = ndimage.gaussian_laplace(ascent, sigma=1) >>> ax1.imshow(result)
>>> result = ndimage.gaussian_laplace(ascent, sigma=3) >>> ax2.imshow(result) >>> plt.show()