def min_resize(x, size, interpolation=cv2.INTER_LINEAR):
 (w, h) = map(float, x.shape[:2])
 if (min([w, h]) != size):
  if (w <= h):
   x = cv2.resize(x, (int(round(((h / w) * size))), int(size)), interpolation=interpolation)
  else:
   x = cv2.resize(x, (int(size), int(round(((w / h) * size)))), interpolation=interpolation)
 return x

def min_resize ( x , size , interpolation = cv2 . INTER_LINEAR ) : ( w , h ) = map ( float , x . shape [ : 2 ] ) if ( min ( [ w , h ] ) != size ) : if ( w <= h ) : x = cv2 . resize ( x , ( int ( round ( ( ( h / w ) * size ) ) ) , int ( size ) ) , interpolation = interpolation ) else : x = cv2 . resize ( x , ( int ( size ) , int ( round ( ( ( w / h ) * size ) ) ) ) , interpolation = interpolation ) return x
resize an image so that it is size along the minimum spatial dimension .