Rotate a batch of images with `scipy.ndimage.interpolation.rotate`

Suppose X

is a tensor numpy.ndarray

that contains a set of color images. For example, a form X

(100, 3, 32, 32)

; that is, we have 100 32x32 rgb images (for example, data provided by the CIFAR dataset).

I want to rotate images in X

and I found out that it can be done using scipy.ndimage.interpolation.rotate scipy function .

However, I can only do it correctly for one image and one color channel at a time, while I would like to apply this function to all images and all color channels at the same time.

What I have tried and is working 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 might look like this:

X_rot = scipy.ndimage.interpolation.rotate(input=X, angle=45, reshape=False)

      

does not work.

Can it be applied scipy.ndimage.interpolation.rotate

for batch of images like tenside numpy.ndarray X

?

Anyway, is there a better way to effectively rotate a batch of images (stored in numpy.ndarray

)?

+3
python scipy rotation batch-processing ndimage


source to share


No one has answered this question yet

Check out similar questions:

1296
Reloading activity on android rotation
7
How to perform tf.image.per_image_standardization on batch of images in tensorflow
five
How to view RGB image using pylab
five
TensorFlow "tf.image" functions in 4D batch upload
2
normalize batch of images in numpy per channel
2
Strange artifacts after rotation with scipy ndimage.rotate (values ​​above 1.0)
1
Rearranging and applying rotations to the MNIST dataset
0
Amplification of learning to predict rotation between two images
0
How to define tuple of form np.reshape (image, (form)) based on image structure
0
Calculating the average and STD for a batch [Python / Numpy]



All Articles
Loading...
X
Show
Funny
Dev
Pics