图片存取一般用unit8
图片的处理一般用float
一、图像读取API
(一)图像读取器
tf.WholeFileReader
(1)将文件的全部内容作为值输出的读取器。
(2)return:读取器实例
(3)read(file_queue):输出将是一个文件名(key)和该文件的内容(值)
(二)图像解码器
1、tf.image.decode_jpeg(contents)
(1)将JPEG编码的图像解码为uint8张量。
(2)return:uint8张量,3-D形状[height, width, channels]
2、tf.image.decode_png(contents)
(1)将PNG编码的图像解码为uint8或uint16张量
(2)return:张量类型,3-D形状[height, width, channels]
二、图片存储:uint8(节约空间)
三、图片计算:float32(提高精度)
四、图片批处理流程
(一)构造图片文件队列
(二)构造图片阅读器
(三)读取图片数据
(四)处理图片数据
例如:
import tensorflow as tf
import os
def picread(filelist):
“”"
读取图片并转换成张量
:param filelist: 文件路径 + 名字的列表
:return:每张图片的张量
“”"
#1、构造文件队列
file_queue = tf.train.string_input_producer(filelist)
#2、构造阅读器去读取图片内容(默认读取一张图片)
reader = tf.WholeFileReader()
key, value = reader.read(file_queue)
print(value)
#3、对读取的图片数据进行解码
image = tf.image.decode_jpeg(value)
print(image)
#4、

最低0.47元/天 解锁文章
1260

被折叠的 条评论
为什么被折叠?



