Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import skimage.io
import skimage.transform
def rescale(img, input_height, input_width):
aspect = img.shape[1] / float(img.shape[0])
if aspect > 1:
return skimage.transform.resize(img, (input_width, int(aspect * input_height)))
elif aspect < 1:
return skimage.transform.resize(img, (int(input_width/aspect), input_height))