I'm trying to rotate an image with keras affine tranformation (theta).
the output i'm reveiving is:
import skimage.io as io
import matplotlib.pyplot as plt
import numpy as np
image = io.imread("dog.jpg")
plt.imshow(image)
plt.show()
import tensorflow as tf
transformed=tf.keras.preprocessing.image.apply_affine_transform(image, theta=45)
plt.imshow(transformed)
plt.show()
What can i do to rotate the image with affine transformation ?
CodePudding user response:
Add row_axis=0, col_axis=1, channel_axis=2 to apply_affine_transform()'s arguments.
Your image's memory layout is "channels-last", but the function thinks it is "channels-first". It (incorrectly) thinks the image laid out as [C,H,W], rather than [H,W,C].
