■ transpose 함수를 사용해 이미지를 회전하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import matplotlib.image as img import matplotlib.pyplot as pp import tensorflow as tf fileName = "d:\\sample.png" ndarray = img.imread(fileName) variable = tf.Variable(ndarray, name = 'x') model = tf.global_variables_initializer() with tf.Session() as sess: variable = tf.transpose(variable, perm = [1, 0, 2]) sess.run(model) transposeNDArray = sess.run(variable) pp.imshow(transposeNDArray) pp.show() |