本文簡要介紹 python 語言中 scipy.ndimage.generic_filter1d
的用法。
用法:
scipy.ndimage.generic_filter1d(input, function, filter_size, axis=-1, output=None, mode='reflect', cval=0.0, origin=0, extra_arguments=(), extra_keywords=None)#
沿給定軸計算一維濾波器。
generic_filter1d
迭代數組的各行,在每一行調用給定的函數。該行的參數是輸入行和輸出行。輸入和輸出線是一維雙數組。輸入線根據濾波器尺寸和原點適當延長。必須根據結果就地修改輸出行。- input: array_like
輸入數組。
- function: {callable, scipy.LowLevelCallable}
沿給定軸應用的函數。
- filter_size: 標量
過濾器的長度。
- axis: 整數,可選
要計算的輸入軸。默認值為 -1。
- 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。
- origin: 整數,可選
控製過濾器在輸入數組像素上的位置。值 0(默認值)使過濾器以像素為中心,正值將過濾器向左移動,負值向右移動。
- extra_arguments: 順序,可選
傳遞給傳遞函數的額外位置參數序列。
- extra_keywords: 字典,可選
要傳遞給傳遞函數的額外關鍵字參數的字典。
- generic_filter1d: ndarray
過濾數組。具有與輸入相同的形狀。
參數 ::
返回 ::
注意:
此函數還接受具有以下簽名之一並包裝在
scipy.LowLevelCallable
中的低級回調函數:int function(double *input_line, npy_intp input_length, double *output_line, npy_intp output_length, void *user_data) int function(double *input_line, intptr_t input_length, double *output_line, intptr_t output_length, void *user_data)
調用函數迭代輸入和輸出數組的行,在每一行調用回調函數。根據調用函數設置的邊界條件擴展當前行,並將結果複製到通過
input_line
傳遞的數組中。輸入行的長度(擴展後)通過input_length
傳遞。回調函數應應用過濾器並將結果存儲在通過output_line
傳遞的數組中。輸出行的長度通過output_length
傳遞。user_data
是按原樣提供給scipy.LowLevelCallable
的數據指針。回調函數必須返回一個整數錯誤狀態,如果出錯則為零,否則為一。如果發生錯誤,您通常應該在返回之前使用信息性消息設置python錯誤狀態,否則調用函數會設置默認錯誤消息。
此外,還接受其他一些低級函數指針規範,但這些規範僅用於向後兼容,不應在新代碼中使用。
相關用法
- Python SciPy ndimage.generic_filter用法及代碼示例
- Python SciPy ndimage.generic_laplace用法及代碼示例
- Python SciPy ndimage.generic_gradient_magnitude用法及代碼示例
- Python SciPy ndimage.generate_binary_structure用法及代碼示例
- Python SciPy ndimage.geometric_transform用法及代碼示例
- Python SciPy ndimage.grey_erosion用法及代碼示例
- Python SciPy ndimage.gaussian_laplace用法及代碼示例
- Python SciPy ndimage.grey_closing用法及代碼示例
- Python SciPy ndimage.gaussian_filter1d用法及代碼示例
- Python SciPy ndimage.gaussian_filter用法及代碼示例
- Python SciPy ndimage.grey_opening用法及代碼示例
- Python SciPy ndimage.gaussian_gradient_magnitude用法及代碼示例
- 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.generic_filter1d。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。