當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy ndimage.grey_closing用法及代碼示例

本文簡要介紹 python 語言中 scipy.ndimage.grey_closing 的用法。

用法:

scipy.ndimage.grey_closing(input, size=None, footprint=None, structure=None, output=None, mode='reflect', cval=0.0, origin=0)#

多維灰度關閉。

灰度閉合包括灰度膨脹和灰度侵蝕的連續。

參數

input array_like

要計算灰度閉合的數組。

size 整數元組

用於灰度閉合的平坦且完整的結構元素的形狀。如果提供了足跡或結構,則可選。

footprint 整數數組,可選

用於灰度關閉的平麵結構元素的非無限元素的位置。

structure 整數數組,可選

用於灰度關閉的結構化元素。結構可以是非平麵結構元素。

output 數組,可選

可以提供用於存儲關閉輸出的數組。

mode {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’},可選

mode 參數確定如何處理數組邊界,其中 cval 是 mode 等於 ‘constant’ 時的值。默認為‘reflect’

cval 標量,可選

如果模式為‘constant’,則填充過去輸入邊的值。默認值為 0.0。

origin 標量,可選

origin 參數控製過濾器的位置。默認 0

返回

grey_closing ndarray

輸入與結構的灰度關閉的結果。

注意

使用平麵結構元素進行灰度閉合的作用相當於平滑深度局部最小值,而二進製閉合填充小孔。

參考

例子

>>> from scipy import ndimage
>>> import numpy as np
>>> a = np.arange(36).reshape((6,6))
>>> a[3,3] = 0
>>> a
array([[ 0,  1,  2,  3,  4,  5],
       [ 6,  7,  8,  9, 10, 11],
       [12, 13, 14, 15, 16, 17],
       [18, 19, 20,  0, 22, 23],
       [24, 25, 26, 27, 28, 29],
       [30, 31, 32, 33, 34, 35]])
>>> ndimage.grey_closing(a, size=(3,3))
array([[ 7,  7,  8,  9, 10, 11],
       [ 7,  7,  8,  9, 10, 11],
       [13, 13, 14, 15, 16, 17],
       [19, 19, 20, 20, 22, 23],
       [25, 25, 26, 27, 28, 29],
       [31, 31, 32, 33, 34, 35]])
>>> # Note that the local minimum a[3,3] has disappeared

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.ndimage.grey_closing。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。