
图像归一化
-
2023年3月6日发(作者:枯叶龟)图像标准化与归⼀化
标准化
原始图像显⽰
[[[232228227]
[233229228]
[233229228]
…
[226223218]
[226223218]
[226223218]]
[[232228227]
[233229228]
[233229228]
…
[226223218]
[226223218]
[226223218]]
[[232228227]
[233229228]
[233229228]
…
[227224219]
[227224219]
[227224219]]
…
importtensorflowastf
importcv2ascv
image=("图⽚⽬录/图⽚名称.png")
("input",image)
y(0)
print(image)
'''
图像标准化
'''
std_image=_image_standardization(image)
print((std_image))
("result",(std_image))
y(0)
'''
图像归⼀化
'''
result=(,dtype=32)
ize(image,result,norm_type=_MINMAX,dtype=_32F)
print(result)
("norm",8(result*255.0))
y(0)
yAllWindows()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[[225221226]
[225221226]
[225221226]
…
[220220220]
[220220220]
[220220220]]
[[225221226]
[225221226]
[225221226]
…
[220220220]
[220220220]
[220220220]]
[[224220225]
[225221226]
[226222227]
…
[220220220]
[220220220]
[220220220]]]
标准化后图像
[[[188175171]
[192178175]
[192178175]
…
[168157140]
[168157140]
[168157140]]
[[188175171]
[192178175]
[192178175]
…
[168157140]
[168157140]
[168157140]]
[[188175171]
[192178175]
[192178175]
…
[171161144]
[171161144]
[171161144]]
…
[[164151168]
[164151168]
[164151168]
…
[147147147]
[147147147]
[147147147]]
[[164151168]
[164151168]
[164151168]
…
[147147147]
[147147147]
[147147147]]
[[161147164]
[164151168]
[168154171]
…
[147147147]
[147147147]
[147147147]]]
脸部全是⿊的
归⼀化后图像
[[[0.9098040.89411770.89019614]
[0.913725550.89803930.8941177]
[0.913725550.89803930.8941177]
…
[0.88627460.87450990.854902]
[0.88627460.87450990.854902]
[0.88627460.87450990.854902]]
[[0.9098040.89411770.89019614]
[0.913725550.89803930.8941177]
[0.913725550.89803930.8941177]
…
[0.88627460.87450990.854902]
[0.88627460.87450990.854902]
[0.88627460.87450990.854902]]
[[0.9098040.89411770.89019614]
[0.913725550.89803930.8941177]
[0.913725550.89803930.8941177]
…
[0.890196140.878431440.8588236]
[0.890196140.878431440.8588236]
[0.890196140.878431440.8588236]]
…
[[0.8823530.866666730.8862746]
[0.8823530.866666730.8862746]
[0.8823530.866666730.8862746]
…
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]]
[[0.8823530.866666730.8862746]
[0.8823530.866666730.8862746]
[0.8823530.866666730.8862746]
…
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]]
[[0.878431440.862745170.882353]
[0.8823530.866666730.8862746]
[0.88627460.87058830.89019614]
…
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]
[0.862745170.862745170.86274517]]
有显⽰结果可知,归⼀化后的图像与原始图像存储的信息是⼀样的,不会有信息损失