import tensorflow as tf
import matplotlib.image as img
import matplotlib.pyplot as plt
sess=tf.InteractiveSession()
image=img.imread(r"C:\Users\origi\Desktop\2\temshow.jpg")
shape=tf.shape(image).eval() # 读取图片的大小
h,w=shape[0],shape[1]
standardization_img=tf.image.per_image_standardization(image) # 图片标准化
fig=plt.figure() # 设置3个画布
fig1=plt.figure()
fig2=plt.figure()
ax=fig.add_subplot(111)
ax.set_title("original image")
ax.imshow(image)
ax2=fig2.add_subplot(111)
ax2.set_title("standardization image")
ax2.imshow(standardization_img.eval())
ax1=fig1.add_subplot(311)
ax1.set_title("original hist")
ax1.hist(sess.run(tf.reshape(image,[h*w,-1]))) # matplotlib.pyplot.figure.hist函数用来画直方图,数据值-出现的频次
ax1=fig1.add_subplot(313)
ax1.set_title("standardization hist")
ax1.hist(sess.run(tf.reshape(standardization_img,[h*w,-1])))
plt.ion()
plt.show()
plt.pause(0)