栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Tensorflow-图像增强api的使用

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Tensorflow-图像增强api的使用

图片的缩放
#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]) //由3维矩阵变为4维

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]) //height:700 weight:1200 passageway: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]) //由3维矩阵变为4维

padded_img  = tf.image.pad_to_bounding_box(img_decoded,[50, 100 , 500, 800]) //x:50 y:100

sess = tf.Session()
img_decoded_val = sess.run(padded_img)
img_decoded_val = img_decoded_val.reshape([800, 800, 3]) //height:700 weight:1200 passageway: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]) //由3维矩阵变为4维

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]) //height:700 weight:1200 passageway:3
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]) //由3维矩阵变为4维

flip_img  = tf.image.adjust_brightness(img_decoded, -0.5) //-0.5光照降低50% 0.5增强50%

sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape([365, 600]) //height:700 weight:1200 passageway:3
img_decoded_val = np.asarrary(img_decoded_val, np.uint8)

printf img_decoded_val.shape

%img_decoded_val
imgshow(img_decoded_val)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/348406.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号