When an arithmetic result exceeds the range of its numeric type, overflow can produce a plausible but incorrect value. For an 8-bit unsigned pixel, adding 5 to 255 yields 4; doubling 255 yields 254. The second result may look reasonable, so checking only the image can miss the error. section 4.2.3
A practical safeguard is to widen the array before arithmetic, cap pixel values at 255, then convert back to an 8-bit type. Choosing a type that is too small can silently corrupt results; test corner cases when memory or speed constraints limit type size. 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")
NumPy example: widen pixel values before doubling, cap them at 255, and convert back to uint8. section 4.2.3






