有時(shí)需要讀取jpg圖像的長(zhǎng)和寬,tensorflow提供了很好的支持
直接上示例
1
2
3
4
5
6
7
8
9
|
decode_jpeg_data = tf.placeholder(dtype = tf.string) decode_jpeg = tf.image.decode_jpeg(decode_jpeg_data, channels = 3 ) image_data = tf.gfile.FastGFile( "C:/Users/shenwei/Desktop/timg.jpg" , 'rb' ).read() print ( len (image_data)) with tf.Session() as sess: image = sess.run(decode_jpeg,feed_dict = {decode_jpeg_data: image_data}) print (image.shape[ 0 ]) print (image.shape[ 1 ]) |
注意看image,shape是(800,800,3) 表示長(zhǎng)為800 寬為800 3個(gè)通道
補(bǔ)充知識(shí):TensorFlow中multiply和matmul的區(qū)別
TensorFlow中multiply是兩個(gè)矩陣之間對(duì)應(yīng)元素相乘,可以是矩陣*矩陣,也可以是矩陣*向量或是矩陣*一個(gè)數(shù);
而matmul則是矩陣相乘,是矩陣行*矩陣列,即a x b。如下所示:
這個(gè)是multiply,矩陣對(duì)應(yīng)元素相乘
這個(gè)是matmul,即行 x 列
以上這篇tensorflow之讀取jpg圖像長(zhǎng)和寬實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/g0415shenw/article/details/86488522