1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from matplotlib.pyplot import imshow
name = './gugong.png' img_string = tf.read_file(name) img_decoded = tf.image.decode_image(img_string) sess = tf.Session() img_decoded_val = sess.run(img_decoded) print(img_decoded_val.shape)
imshow(img_decoded_val)
plt.show()
name = './gugong.png' img_string = tf.read_file(name) img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 402, 600, 3]) resize_img = tf.image.resize_bicubic(img_decoded, [804,1200]) sess = tf.Session() img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape([804,1200,3]) img_decoded_val = np.asarray(img_decoded_val, np.uint8) print(img_decoded_val.shape)
imshow(img_decoded_val)
plt.show()
name = './gugong.png' img_string = tf.read_file(name) img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 402, 600, 3]) padded_img = tf.image.pad_to_bounding_box(img_decoded, 50, 100, 500, 800) sess = tf.Session() img_decoded_val = sess.run(padded_img)
img_decoded_val = img_decoded_val.reshape([500, 800, 3]) img_decoded_val = np.asarray(img_decoded_val, np.uint8) print(img_decoded_val.shape)
imshow(img_decoded_val)
plt.show()
name = './gugong.png' img_string = tf.read_file(name) img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 402, 600, 3]) fliped_img = tf.image.flip_up_down(img_decoded) sess = tf.Session() img_decoded_val = sess.run(fliped_img)
img_decoded_val = img_decoded_val.reshape([402, 600, 3]) img_decoded_val = np.asarray(img_decoded_val, np.uint8) print(img_decoded_val.shape)
imshow(img_decoded_val)
plt.show()
name = './gugong.png' img_string = tf.read_file(name) img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 402, 600, 3]) brightness_img = tf.image.random_brightness(img_decoded, 1) sess = tf.Session() img_decoded_val = sess.run(brightness_img)
img_decoded_val = img_decoded_val.reshape([402, 600, 3]) img_decoded_val = np.asarray(img_decoded_val, np.uint8) print(img_decoded_val.shape)
imshow(img_decoded_val)
plt.show()
|