Python中的图像规范化

2024-04-26 09:28:58 发布

您现在位置:Python中文网/ 问答频道 /正文

图像文件如下:

file = misc.imread("....\image_123.png")
Image.fromarray(file,'L')

image

^{pr2}$

文件中像素值的范围:

print ("min = %s, max = %s"% (np.min(file1), np.max(file1)))
min = 0, max = 239

我想应用一个标准的标准化,比如从像素值中减去255/2,然后除以255

file_mod = (file.astype(float) - 255/2)/255

下一步,当我试图可视化标准化图像时,我看到一个完全扭曲的输出:

enter image description here

甚至像下面这样的东西也会扭曲图像:

file_mod = (file.astype(float) - 0.0)/1.0

请帮助处理标准化方法。在


Tags: 图像imagemodpng图像文件np像素float