Let's suppose that X
is a numpy.ndarray
tensor that holds a set of color images. For instance, X
's shape is (100, 3, 32, 32)
; i.e., we have 100 32x32 rgb images (such as those provided by the CIFAR dataset).
I want to rotate the images in X
and I found out that this could be done using the scipy.ndimage.interpolation.rotate function of scipy.
However, I can do it correctly only for a single image and a single color channel each time, while I would like to apply the function for all images and all color channels at once.
What I tried and it works so far is the following:
import scipy.ndimage.interpolation
image = X[0,0,:,:]
rotated_image = scipy.ndimage.interpolation.rotate(input=image, angle=45, reshape=False)
but what I want to do, which could look like this
X_rot = scipy.ndimage.interpolation.rotate(input=X, angle=45, reshape=False)
does not work.
Is there any way to apply scipy.ndimage.interpolation.rotate
for a batch of images like the numpy.ndarray tensor X
?
In any case, is there any better way to rotate a batch of images (stored in a numpy.ndarray
) efficiently?