使用`scipy.ndimage.interpolation.rotate`旋转一批图像

时间:2017-06-23 12:24:52

标签: python scipy rotation batch-processing ndimage

我们假设X是一个numpy.ndarray张量,它包含一组彩色图像。例如,X的形状为(100, 3, 32, 32);即,我们有100个32x32 rgb图像(例如CIFAR数据集提供的图像)。

我想在X中旋转图像,我发现可以使用scipy的scipy.ndimage.interpolation.rotate函数完成此操作。

但是,我每次只能对单个图像和单个颜色通道进行正确的操作,而我想立即对所有图像和所有颜色通道应用该功能。

我尝试了它到目前为止的工作如下:

import scipy.ndimage.interpolation

image = X[0,0,:,:]
rotated_image = scipy.ndimage.interpolation.rotate(input=image, angle=45, reshape=False)

但我想做什么,看起来像这样

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

不起作用。

有没有办法将scipy.ndimage.interpolation.rotate应用于numpy.ndarray张量X等一批图片?

在任何情况下,有没有更好的方法来有效地旋转一批图像(存储在numpy.ndarray)?

0 个答案:

没有答案