An 8-bit unsigned integer represents grayscale pixel values from 0 through 255. In NumPy, arithmetic that exceeds this range wraps: 255 + 5 becomes 4, while doubling 255 produces 254. Images can look plausible despite these incorrect values. section 4.2.3
brighter3_arr = image_arr.astype(np.uint16)
brighter3_arr = brighter3_arr * 2
print(brighter3_arr.max(), brighter3_arr.dtype)
brighter3_arr = np.minimum(brighter3_arr, 255) #1
print(brighter3_arr.max(), brighter3_arr.dtype)
brighter3_arr = brighter3_arr.astype(np.uint8)
print(brighter3_arr.max(), brighter3_arr.dtype)
Image.fromarray(brighter3_arr).save("brighter3.png")
Widen the array to uint16 before doubling, clamp results to 255, then cast back to uint8 for the image. section 4.2.3








