tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 0 of dimension
0 out of bounds. for 'strided_slice' (op: 'StridedSlice') with input shapes: [0], [1], [1
], [1] and with computed input tensors: input[1] = <0>, input[2] = <1>, input[3] = <1>.
使用tensorflow处理图片是遇到这样的问题,错误原因:
.....
img = tf.read_file(src)
img_org = tf.image.decode_jpeg(img)
.....
我把使用tf.read_file读取的文件直接送去处理,这样就会报出上面的错误。正确的做法是读取后利用image.decode_jpeg函数去进行解码。
小知识:
一张RGB图像可以看成一个三维的矩阵,矩阵中的每一个数表示了图像上不同位置,不同颜色的亮度。然而图像在存储时并不是直接记录这些矩阵中的数字,而是记录经过压缩编码之后的结果。所以要将一张图象还原成一个三维矩阵。需要解码的过程。