本文簡要介紹 python 語言中 numpy.dstack
的用法。
用法:
numpy.dstack(tup)
按順序深度(沿第三軸)堆疊數組。
這相當於在二維形狀數組之後沿第三軸串聯(M,N)已被重塑為(M,N,1)和一維形狀數組(N,)已被重塑為(1,N,1)。重建數組除以numpy.dsplit.
此函數對最多 3 維的數組最有意義。例如,對於具有高度(第一軸)、寬度(第二軸)和 r/g/b 通道(第三軸)的 pixel-data。函數
concatenate
、stack
和block
提供更通用的堆疊和連接操作。- tup: 數組序列
除了第三個軸之外,陣列必須具有相同的形狀。一維或二維數組必須具有相同的形狀。
- stacked: ndarray
通過堆疊給定數組形成的數組將至少是 3D 的。
參數:
返回:
例子:
>>> a = np.array((1,2,3)) >>> b = np.array((2,3,4)) >>> np.dstack((a,b)) array([[[1, 2], [2, 3], [3, 4]]])
>>> a = np.array([[1],[2],[3]]) >>> b = np.array([[2],[3],[4]]) >>> np.dstack((a,b)) array([[[1, 2]], [[2, 3]], [[3, 4]]])
相關用法
- Python numpy dsplit用法及代碼示例
- Python numpy dtype.isbuiltin用法及代碼示例
- Python numpy dtype.shape用法及代碼示例
- Python numpy dtype.ndim用法及代碼示例
- Python numpy dtype.alignment用法及代碼示例
- Python numpy diagonal用法及代碼示例
- Python numpy dtype用法及代碼示例
- Python numpy dtype.names用法及代碼示例
- Python numpy dtype.__class_getitem__用法及代碼示例
- Python numpy divmod用法及代碼示例
- Python numpy dtype.flags用法及代碼示例
- Python numpy diagflat用法及代碼示例
- Python numpy dtype.fields用法及代碼示例
- Python numpy dtype.subdtype用法及代碼示例
- Python numpy delete用法及代碼示例
- Python numpy dtype.descr用法及代碼示例
- Python numpy dec.setastest用法及代碼示例
- Python numpy datetime_as_string用法及代碼示例
- Python numpy divide用法及代碼示例
- Python numpy dtype.kind用法及代碼示例
- Python numpy dtype.metadata用法及代碼示例
- Python numpy diag用法及代碼示例
- Python numpy dec.slow用法及代碼示例
- Python numpy dtype.newbyteorder用法及代碼示例
- Python numpy digitize用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.dstack。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。