VITA-Group / EnlightenGAN

[IEEE TIP] "EnlightenGAN: Deep Light Enhancement without Paired Supervision" by Yifan Jiang, Xinyu Gong, Ding Liu, Yu Cheng, Chen Fang, Xiaohui Shen, Jianchao Yang, Pan Zhou, Zhangyang Wang
Other
890 stars 198 forks source link

why does image_numpy need to add one,and divide 2,finally multipy 255 #123

Closed woaiwojia4816294 closed 2 years ago

woaiwojia4816294 commented 2 years ago

hello, i have a question about function tensor2im in util.py why does image_numpy need to add one, then divide two,finally multipy 255. Thanks a lot def tensor2im(image_tensor, imtype=np.uint8): image_numpy = image_tensor[0].cpu().float().numpy() image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + 1) / 2.0 * 255.0 image_numpy = np.maximum(image_numpy, 0) image_numpy = np.minimum(image_numpy, 255) return image_numpy.astype(imtype)

yifanjiang19 commented 2 years ago

This is scaling transformation from [-1, 1] to [0, 255]