Skip to content

Instantly share code, notes, and snippets.

@ChongyeWang
Last active March 15, 2019 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChongyeWang/a4dff04578d5a99d911ad38518cf6704 to your computer and use it in GitHub Desktop.
Save ChongyeWang/a4dff04578d5a99d911ad38518cf6704 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
# load our input image
image = cv2.imread('images/input.jpg')
# Let's make our image 3/4 of it's original size
image_scaled = cv2.resize(image, None, fx=0.75, fy=0.75)
cv2.imshow('Scaling - Linear Interpolation', image_scaled)
cv2.waitKey()
# Let's double the size of our image
img_scaled = cv2.resize(image, None, fx=2, fy=2, interpolation = cv2.INTER_CUBIC)
cv2.imshow('Scaling - Cubic Interpolation', img_scaled)
cv2.waitKey()
# Let's skew the re-sizing by setting exact dimensions
img_scaled = cv2.resize(image, (900, 400), interpolation = cv2.INTER_AREA)
cv2.imshow('Scaling - Skewed Size', img_scaled)
cv2.waitKey()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment