def save_images(images, size, image_path, color=True):
h, w = images.shape[1], images.shape[2]
if color is True:
img = np.zeros((h * size[0], w * size[1], 3))
else:
img = np.zeros((h * size[0], w * size[1]))
for idx, image in enumerate(images):
i = idx % size[1]
j = math.floor(idx / size[1])
if color is True:
img[j*h:j*h+h, i*w:i*w+w, :] = image
else:
img[j*h:j*h+h, i*w:i*w+w] = image
if color is True:
scipy.misc.toimage(rescale_image(img),
cmin=0, cmax=255).save(image_path)
else:
scipy.misc.toimage(rescale_dm(img), cmin=0, cmax=65535,
low=0, high=65535, mode='I').save(image_path)
评论列表
文章目录