Last active
July 2, 2020 01:47
-
-
Save vicotrbb/297b472626942e038ee899600f1350a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 # openCV | |
import numpy as np | |
def image_resize(image, width = None, height = None): | |
img = cv2.imread(image) | |
dim = None | |
(h, w) = image.shape[:2] | |
if width is None: | |
r = height / float(h) | |
dim = (int(w * r), height) | |
else: | |
r = width / float(w) | |
dim = (width, int(h * r)) | |
resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA) | |
return resized |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment