用法:
skimage.filters.gaussian(image, sigma=1, output=None, mode='nearest', cval=0, multichannel=None, preserve_range=False, truncate=4.0, *, channel_axis=None)
多維高斯濾波器。
- image:array-like
輸入圖像(灰度或彩色)進行過濾。
- sigma:標量或標量序列,可選
高斯核的標準差。每個軸的高斯濾波器的標準偏差作為一個序列或單個數字給出,在這種情況下,它對所有軸都是相等的。
- output:數組,可選
output
參數傳遞一個用於存儲過濾器輸出的數組。- mode:{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’},可選
mode
參數確定如何處理數組邊界,其中cval
是 mode 等於 ‘constant’ 時的值。默認為‘nearest’。- cval:標量,可選
如果
mode
是‘constant’,則填充過去輸入邊的值。默認值為 0.0- multichannel:布爾值,可選(默認值:無)
圖像的最後一個軸是否被解釋為多個通道。如果為 True,則單獨過濾每個通道(通道不混合在一起)。僅支持 3 個通道。如果
None
,當數組的形狀為 (M, N, 3) 時,該函數將嘗試猜測這一點,並在不明確時發出警告。此參數已棄用:指定channel_axis反而。- preserve_range:布爾型,可選
如果為 True,則保留原始值範圍。否則,輸入
image
將根據img_as_float
的約定進行轉換(首先標準化為值 [-1.0 ; 1.0] 或 [0 ; 1.0],具體取決於輸入的 dtype)有關更多信息,請參閱:https://scikit-image.org/docs/dev/user_guide/data_types.html
- truncate:浮點數,可選
在這麽多標準偏差處截斷過濾器。
- channel_axis:int 或無,可選
如果為 None,則假定圖像是灰度(單通道)圖像。否則,此參數指示數組的哪個軸對應於通道。
- filtered_image:ndarray
過濾後的數組
- multichannel:DEPRECATED
已棄用以支持channel_axis。
參數:
返回:
其他參數:
注意:
此函數是
scipy.ndi.gaussian_filter()
的包裝器。整數數組轉換為浮點數。
output
應該是浮點數據類型,因為提供的高斯轉換為浮點數image
。如果沒有提供output
,將分配另一個數組並作為結果返回。多維濾波器被實現為一係列一維卷積濾波器。中間數組存儲在與輸出相同的數據類型中。因此,對於精度有限的輸出類型,結果可能不精確,因為存儲的中間結果可能精度不足。
例子:
>>> a = np.zeros((3, 3)) >>> a[1, 1] = 1 >>> a array([[0., 0., 0.], [0., 1., 0.], [0., 0., 0.]]) >>> gaussian(a, sigma=0.4) # mild smoothing array([[0.00163116, 0.03712502, 0.00163116], [0.03712502, 0.84496158, 0.03712502], [0.00163116, 0.03712502, 0.00163116]]) >>> gaussian(a, sigma=1) # more smoothing array([[0.05855018, 0.09653293, 0.05855018], [0.09653293, 0.15915589, 0.09653293], [0.05855018, 0.09653293, 0.05855018]]) >>> # Several modes are possible for handling boundaries >>> gaussian(a, sigma=1, mode='reflect') array([[0.08767308, 0.12075024, 0.08767308], [0.12075024, 0.16630671, 0.12075024], [0.08767308, 0.12075024, 0.08767308]]) >>> # For RGB images, each is filtered separately >>> from skimage.data import astronaut >>> image = astronaut() >>> filtered_img = gaussian(image, sigma=1, channel_axis=-1)
相關用法
- Python skimage.filters.gabor用法及代碼示例
- Python skimage.filters.gabor_kernel用法及代碼示例
- Python skimage.filters.unsharp_mask用法及代碼示例
- Python skimage.filters.rank.noise_filter用法及代碼示例
- Python skimage.filters.threshold_otsu用法及代碼示例
- Python skimage.filters.rank.sum用法及代碼示例
- Python skimage.filters.window用法及代碼示例
- Python skimage.filters.rank.autolevel用法及代碼示例
- Python skimage.filters.threshold_li用法及代碼示例
- Python skimage.filters.rank.pop用法及代碼示例
- Python skimage.filters.rank.mean用法及代碼示例
- Python skimage.filters.rank.pop_bilateral用法及代碼示例
- Python skimage.filters.rank.maximum用法及代碼示例
- Python skimage.filters.roberts用法及代碼示例
- Python skimage.filters.rank.equalize用法及代碼示例
- Python skimage.filters.rank.enhance_contrast用法及代碼示例
- Python skimage.filters.rank.gradient用法及代碼示例
- Python skimage.filters.LPIFilter2D.__init__用法及代碼示例
- Python skimage.filters.farid用法及代碼示例
- Python skimage.filters.rank_order用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.filters.gaussian。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。