Avoid overflow when adding numpy arrays
You can achieve this by creating a third array of dtype uint8, plus a bool array (which together are more memory efficient that one uint16 array). np.putmask is useful for avoiding a temp array. a = np.array([100, 200, 250], dtype=np.uint8) b = np.array([50, 50, 50], dtype=np.uint8) c = 255 – b # a temp uint8 … Read more