图片的缩放
#resize
#tf.image.resize_area
#tf.image.resize_bicubic
#tf.image.resize_nearest_neighbor
name = './图片.jgp'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded,[1,365,600,3])
resize_img = tf.image.resize_bicubic(img_decoded,[730,1200])
sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape([730,1200,3])
img_decoded_val = np.asarrary(img_decoded_val, np.uint8)
printf img_decoded_val.shape
%img_decoded_val
imgshow(img_decoded_val)
图片的裁剪
#crop
#tf.image.pad_to_bounding_box
#tf.image.crop_to_bounding_box
#tf.random_crop
name = './图片.jgp'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded,[1,365,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([800, 800, 3])
img_decoded_val = np.asarrary(img_decoded_val, np.uint8)
printf img_decoded_val.shape
%img_decoded_val
imgshow(img_decoded_val)
图片的翻转
#flip
#tf.image.flip_up_down
#tf.image.flip_left_right
#tf.image.random_flip_up_down
#tf.image.random_flop_lefr_right
name = './图片.jgp'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded,[1,365,600,3])
flip_img = tf.image.flip_up_down(img_decoded)
sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape([365, 600])
img_decoded_val = np.asarrary(img_decoded_val, np.uint8)
printf img_decoded_val.shape
%img_decoded_val
imgshow(img_decoded_val)
改变光照
#brightness
#tf.image.adjust_brightness
#tf.image.random_brightness
#tf.image.adjust_constrast
#tf.image.random_constrast
name = './图片.jgp'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded,[1,365,600,3])
flip_img = tf.image.adjust_brightness(img_decoded, -0.5)
sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape([365, 600])
img_decoded_val = np.asarrary(img_decoded_val, np.uint8)
printf img_decoded_val.shape
%img_decoded_val
imgshow(img_decoded_val)