I'm working with Python 3.
I have a variable data from type unit8 and size (60000, 1, 28, 28), what means, that I have 60000 images with 1 channel and a size of 28x28 pixels.
Now I like to resize the images to 60x60 pixels, so that I get a size of (60000, 1, 60, 60)
Can someone help me?
Following solution worked for me. After list comprehension the list will be stacked back to a batch with numpy:
import cv2
import numpy as np
target_shape = (60, 60)
def _resize_image(image, target):
return cv2.resize(image, dsize=(target[0], target[1]), interpolation=cv2.INTER_LINEAR)
image = [_resize_image(image=i, target=target_shape) for i in data]
data_batch = np.stack(image, axis=0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With