import matplotlib
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
import os
os.getcwd()
img_raw_data = tf.gfile.FastGFile('cat.jpeg', 'rb').read()
img_data = tf.image.decode_jpeg(img_raw_data)
with tf.Session() as sess:
resized = tf.image.resize_images(img_data, [300, 300], method=0)
cat = np.asarray(resized.eval(), dtype='uint8')
plt.imshow(cat)
plt.show()
croped = tf.image.resize_image_with_crop_or_pad(img_data, 300, 300)
padded = tf.image.resize_image_with_crop_or_pad(img_data, 3000, 3000)
plt.imshow(croped.eval())
plt.show()
plt.imshow(padded.eval())
plt.show()
transposed = tf.image.transpose_image(img_data)
plt.imshow(transposed.eval())
plt.show()
adjusted = tf.image.random_brightness(img_data, max_delta=0.5)
plt.imshow(adjusted.eval())
plt.show()
adjusted = tf.image.adjust_hue(img_data, 0.1)
plt.imshow(adjusted.eval())
plt.show()
项目源代码请点击这里