def gen_image(img, width, height, outfile, img_type='grey'):
    """Save an image with the given parameters."""
    assert len(img) == width * height or len(img) == width * height * 3

    if img_type == 'grey':
        misc.imsave(outfile, img.reshape(width, height))

    elif img_type == 'color':
        misc.imsave(outfile, img.reshape(3, width, height))
Save an image with the given parameters.
yadlt/utils/utilities.py