File size: 380 Bytes
6aab31e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import cv2
def resize_image(image, width=None, height=None):
if width is None and height is None:
return image
(h, w) = image.shape[:2]
if width is None:
ratio = height / float(h)
width = int(w * ratio)
else:
ratio = width / float(w)
height = int(h * ratio)
return cv2.resize(image, (width, height))
|