Numpy属性dtype的转换(数据类型转换):unit8和float32转
转载
查看数据类型
print(image.dtype)
uint8转换成float32
先将图片转化为float32类型, 再除以255, 得到0-1之间的数
import numpy as np
image = image.astype(np.float32)/255
float转换成uint8
先乘以255,再转化为uint8
import numpy as np
image = (image*255).astype(np.uint8)