image resizing

|
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import imageio
import scipy.misc

im = imageio.imread('test.jpg')  # 읽고
plt.imshow(im)
print(im.shape)
(1044, 1179, 3)

output_1_1.png

i_width = 32
i_height = 32

im2 = scipy.misc.imresize(im, (i_height, i_width))  # resize
plt.imshow(im2)
print(im2.shape)
(32, 32, 3)

output_3_1.png

im2 = im2.astype(np.float32)
im2 = im2/255.0