numpy uint8 pixel wrapping solution

Use numpy.clip:

import numpy as np
np.clip(data32, 0, 255, out=data32)
data_u8 = data32.astype('uint8')

Note that you can also brighten images without numpy this way:

import ImageEnhance
enhancer = ImageEnhance.Brightness(img)
outimg = enhancer.enhance(1.2)
outimg.save('out.png')

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)