用法:
scipy.ndimage.sum(input, labels=None, index=None)
計算數組值的總和。
參數:
- input:array_like
標簽定義的區域內的輸入值相加。
- labels:array_like of ints, 可選參數
將標簽分配給數組的值。必須具有與輸入相同的形狀。
- index:array_like, 可選參數
要測量的對象的單個標簽號或標簽號序列。
返回值:
- sum:ndarray或標量
由具有與索引相同形狀的標簽定義的區域內的輸入值的總和的數組。如果‘index’為None或標量,則返回標量。
例子:
>>> from scipy import ndimage >>> input = [0,1,2,3] >>> labels = [1,1,2,2] >>> ndimage.sum(input, labels, index=[1,2]) [1.0, 5.0] >>> ndimage.sum(input, labels, index=1) 1 >>> ndimage.sum(input, labels) 6
源碼:
scipy.ndimage.sum的API實現見:[源代碼]
相關用法
注:本文由純淨天空篩選整理自 scipy.ndimage.sum。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。