简体   繁体   中英

Python3 numpy array addition

import numpy as np

pp = np.array(p)       # p is some array

print(pp[0])
print(pp[1])
print(pp[0] + pp[1])

results in : [138 138 138]
         [138 138 148]
         [20 20 40]

Why does this happen? Why is the addition wrong?

Your array is evidently composed of unsigned bytes (dtype=uint8). Your values are wrapping around within the 0..255 range of this data type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM