Skip to content

Instantly share code, notes, and snippets.

@init27
Last active August 31, 2018 16:59
Show Gist options
  • Save init27/87f13a7b128da74ac88f8d4a742f11d1 to your computer and use it in GitHub Desktop.
Save init27/87f13a7b128da74ac88f8d4a742f11d1 to your computer and use it in GitHub Desktop.
import argparse
import cv2
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow("Original", image)
cv2.imwrite("data/gray.jpg",gray)
r = 500.0 / image.shape[1]
dim = (500, int(image.shape[0] * r))
resized = cv2.resize(image, dim, interpolation=cv2.INTER_AREA)
cv2.imshow("Resized (Width)", resized)
cv2.imwrite("data/ResizedImage.jpg",resized)
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment