I have close to 10000 greyscale images in a numpy array (10000 x 480 x 752) and would like to resize them with the imresize function from scipy.misc. It works with a for loop build around all the images, but it takes 15 minutes.
images_resized = np.zeros([0, newHeight, newWidth], dtype=np.uint8)
for image in range(images.shape[0]):
temp = imresize(images[image], [newHeight, newWidth], 'bilinear')
images_resized = np.append(images_resized, np.expand_dims(temp, axis=0), axis=0)
Is there any way to do this faster with an apply like function? I looked into apply_along_axis
def resize_image(image):
return imresize(image, [newHeight, newWidth], 'bilinear')
np.apply_along_axis(lambda x: resize_image(x), 0, images)
but this gives an
'arr' does not have a suitable array shape for any mode
error.