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 i
th 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
Post a Comment