how can i put (keras/apply_affine_transform) to work ? (theta)

Issue

I’m trying to rotate an image with keras affine tranformation (theta).
the output i’m reveiving is:

output here

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 ?

Solution

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].

Answered By – vasiliykarasev

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published