TensorflowとNumpyの概念を学び始めました。私は、Tensorflowを使っていろいろな形の画像を、固定された1つの形状に作り直しています。そのために、私はループを利用しています。ループの最後に、この再構成されたイメージを1つの配列に蓄積しています。さて、この配列から画像をプロットすると、ぼやけた画像が得られます。しかし、Tensorflowを使って再構成されたイメージのインスタンスをプロットすると、正しいイメージが得られます。誰にでも私がどこで間違っているのか説明できますか?割り当て後の画像がぼやけた
コード:
fixedW = 227.0
fixedH = 227.0
X_data = np.zeros((3, fixedW, fixedH, 3), dtype = np.float32) # Only 3 images in this example
tf.reset_default_graph()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(3):
img = matplotlib.image.imread(image_file_name[i])
preshape = img.shape
img = np.reshape(img, (1, preshape[0], preshape[1], preshape[2])) #Make it single batched image
tf_img = tf.image.resize_images(img, (fixedW, fixedH), tf.image.ResizeMethod.NEAREST_NEIGHBOR)
resized_img = sess.run(tf_img)[0]
print(resized_img.shape) # Prints correctly
X_data[i, :, :, :] = resized_img[:, :, :] # Something is wrong here
# This plots correctly
plt.imshow(resized_img)
plt.show()
# This plots some blurred image
plt.imshow(X_data[2])
plt.show()
私はこれで間違っているつもりだと私は私の理解では、ここで何考え方をしないのですどこ誰もが私を説明することができますしてくださいこの割り当ての。