python 图片处理(更新)

查看数据类型
print(image.dtype)
1
unit8 转换成 float32
先将图片转化为float32类型,再除以255,得到0-1之间的数

import numpy as np
image = image.astype(np.float32) / 255
1
2
float32 转换成 uint8
每个数乘以255,再转化为uint8

import numpy as np
image = (image * 255).astype(np.uint8)

原文地址:https://www.cnblogs.com/shanyr/p/14507710.html