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)

posted on 2021-03-09 19:52  若流芳千古  阅读(342)  评论(0编辑  收藏  举报

导航