![](/img/trans.png)
[英]How to change a specific numpy array inside a arrays of arrays?
[英]How to change values for axis in array of arrays (of arrays of arrays) in NumPy?
我有一個4級 4維數組contours
( cv2.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.