はあなたが望むものを達成する全体のコードです:
import numpy as np
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.path.dirname(os.path.realpath(__file__))
filename = dir_path + "/MarshOrchid.jpg"
image = mpimg.imread(filename)
height, width, depth = image.shape
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
left_part = tf.slice(x, [0, 0, 0], [height, width/2, depth]) #Extract Left part
rigth_part = tf.slice(x, [0, width/2, 0], [height, width/2, depth]) #Extract Right part
left_part = tf.reverse_sequence(left_part, np.ones((height,)) * width/2, 1, batch_dim=0) #Reverse Left Part
rigth_part = tf.reverse_sequence(left_part, np.ones((height,)) * width/2, 1, batch_dim=0) #Reverse Right Part
x = tf.concat([left_part, rigth_part],1) #Concat them together along the second edge (the width)
result = session.run(x)
print(result.shape)
plt.imshow(result)
plt.show()
これらのコードはthis tutorial.
ドの最後の行使のためのソリューションです。ミラーリングされたイメージを生成するノードをTensorflowグラフに作成するか、結果をnumpy配列にしたいだけですか? –
ノードは素晴らしいでしょう –