tensorflow 图像数据处理
2017-09-22 17:00
246 查看
一、图像解编码、尺寸调整
TensorFlow提供了常用图片格式(包括png和jpeg)的解码和编码操作,下面用一个jpg的图像演示:
import matplotlib.pyplotas plt
import tensorflowas tf
image_raw_data = tf.gfile.FastGFile('.//image//img.jpg','rb').read()
with tf.Session()as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
print(img_data.eval())
plt.imshow(img_data.eval())
plt.show()
img_data = tf.image.convert_image_dtype(img_data,dtype = tf.float32)
encoded_image = tf.image.encode_jpeg(img_data)
with tf.gfile.GFile(".//image//img1.jpg","wb")as
f:
f.write(encoded_image.eval())
tf.image.decode_jpeg为jpg解码过程,tf.image.encode_jpeg为jpg编码过程。
图像尺寸调整有三个函数:tf.image.resize_images、tf.image.resize_image_with_crop_or_pad、tf.image.central_crop。
TensorFlow提供了常用图片格式(包括png和jpeg)的解码和编码操作,下面用一个jpg的图像演示:
import matplotlib.pyplotas plt
import tensorflowas tf
image_raw_data = tf.gfile.FastGFile('.//image//img.jpg','rb').read()
with tf.Session()as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
print(img_data.eval())
plt.imshow(img_data.eval())
plt.show()
img_data = tf.image.convert_image_dtype(img_data,dtype = tf.float32)
encoded_image = tf.image.encode_jpeg(img_data)
with tf.gfile.GFile(".//image//img1.jpg","wb")as
f:
f.write(encoded_image.eval())
tf.image.decode_jpeg为jpg解码过程,tf.image.encode_jpeg为jpg编码过程。
图像尺寸调整有三个函数:tf.image.resize_images、tf.image.resize_image_with_crop_or_pad、tf.image.central_crop。
相关文章推荐
- TensorFlow:实战Google深度学习框架(六)图像数据处理
- tensorflow 图像数据处理(二)
- Tensorflow--图像数据处理
- 深度学习框架Tensorflow学习与应用 图像数据处理之一
- tensorflow 图像数据处理(一)
- 深度学习框架Tensorflow学习与应用 图像数据处理之二
- TensorFlow图像数据处理
- tensorflow图像数据处理
- tensorflow处理自己的图像数据(不使用队列)
- Tensorflow图像预处理,Numpy读取数据踩坑
- 彩色图像流、深度数据和骨骼点跟踪的集合处理
- 12、TensorFlow 图像处理
- 获取RGB图像的单个点的数据-视频处理基础(1)
- Android处理图像数据转换的各种方法
- 分段OTSU处理图像数据
- TensorFlow图像数据预处理
- Python空间数据处理1: GDAL读写遥感图像
- 一个贯穿图像处理与数据挖掘的永恒问题
- 【Tensorflow】怎样为你的网络预加工和打包训练数据?(二):小数据集的处理方案
- 数据图像处理程序代写