簡體   English   中英

如何在NumPy中更改數組數組中的軸的值?

[英]How to change values for axis in array of arrays (of arrays of arrays) in NumPy?

我有一個4級 4維數組contourscv2.findContours結果),在其末尾有一對坐標。 看起來像這樣:

print(contours[0][0])
→ [[ 676 4145]]
print(contours[0][0][0])
→ [ 676 4145]
print(contours[0][0][0][1])
→ 4145

我想編輯每個最后一級數組的元素1,以使該值大10。我知道文檔 ,但是我不知道如何深化而不展平。 怎么做?

這些中的任何一個都可以工作:

  • contours[:,:,:,1] += 10
  • contours[...,1] += 10
  • contours += [0, 10]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM