图片存取一般用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):
“”"
读取图片并转换成张量