def upscale(image, ratio):
 if (not isinstance(image, np.ndarray)):
  raise ValueError('Expected ndarray')
 if (ratio < 1):
  raise ValueError(('Ratio must be greater than 1 (ratio=%f)' % ratio))
 width = int(math.floor((image.shape[1] * ratio)))
 height = int(math.floor((image.shape[0] * ratio)))
 channels = image.shape[2]
 out = np.ndarray((height, width, channels), dtype=np.uint8)
 for (x, y) in np.ndindex((width, height)):
  out[(y, x)] = image[(int(math.floor((y / ratio))), int(math.floor((x / ratio))))]
 return out

def upscale ( image , ratio ) : if ( not isinstance ( image , np . ndarray ) ) : raise ValueError ( 'Expected ndarray' ) if ( ratio < 1 ) : raise ValueError ( ( 'Ratio must be greater than 1 (ratio=%f)' % ratio ) ) width = int ( math . floor ( ( image . shape [ 1 ] * ratio ) ) ) height = int ( math . floor ( ( image . shape [ 0 ] * ratio ) ) ) channels = image . shape [ 2 ] out = np . ndarray ( ( height , width , channels ) , dtype = np . uint8 ) for ( x , y ) in np . ndindex ( ( width , height ) ) : out [ ( y , x ) ] = image [ ( int ( math . floor ( ( y / ratio ) ) ) , int ( math . floor ( ( x / ratio ) ) ) ) ] return out
return upscaled image array arguments: image -- a numpy .