resize image of a 4-dimensional array in python -


i'm working python 3.

i have variable data type unit8 , size (60000, 1, 28, 28), means, have 60000 images 1 channel , size of 28x28 pixels.
resize images 60x60 pixels, size of (60000, 1, 60, 60)

can me?

if have opencv can resize using,

img = pics[i][0] new_img = cv2.resize(img, none, fx=2, fy=2, interpolation = cv2.inter_cubic) 

now ith image resized factor 2 both x , y directions (here pics numpy array (60000, 1, 28, 28) images). if don't use opencv, can install (search google)

if not can use pil package. can install using,

pip install pillow 

and use following code resize.

from pil import image img = pics[i][0] im = image.fromarray(np.rollaxis(img, 0,3)) new_im = im.resize((new_x, new_y), image.bicubic) 

you can use for loop put these images array of (60000, 1, x ,y)


Comments

Popular posts from this blog

php - Cannot override Laravel Spark authentication with own implementation -

What is happening when Matlab is starting a "parallel pool"? -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -