python-scipy.misc.imresize()関数



Python Scipy Misc Imresize Function



一般的な名前などのこの機能は、画像の形状を再調整するために使用されます〜

import scipy.misc import numpy as np def imread(path): img = scipy.misc.imread(path).astype(np.float) if len(img.shape) == 2: # grayscale img = np.dstack((img,img,img)) elif img.shape[2] == 4: # PNG with alpha channel img = img[:,:,:3] return img content_image = imread ( 'examples / 1.jpg') # image read content print (content_image.shape) # original shape content_image1 = scipy.misc.imresize(content_image, (200,500)) print (content_image1.shape) # enter a fixed shape resizing content_image2 = scipy.misc.imresize(content_image, 0.5) (Content_image2.shape) # print ratio adjustment input shape content_image3 = scipy.misc.imresize(content_image, 5) print (content_image3.shape) # Enter a number greater than 1, the default percentage. 5 example, the input is equal to 5%