-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRescale_Image.py
38 lines (32 loc) · 959 Bytes
/
Rescale_Image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Import the modules
import cv2
import numpy as np
import argparse as ap
import imutils
# Make sure to run this code only once for a single image, running it multiple times will shrink the image smaller and smaller
parser = ap.ArgumentParser()
parser.add_argument("-i", "--image", help="Path to Image", required="True")
args = vars(parser.parse_args())
# # Read the input image
# im =
#
# scale_percent = 40 # Percent of original size
# width = int(im.shape[1] * scale_percent / 100)
# height = int(im.shape[0] * scale_percent / 100)
# dim = (width, height)
#
# # resize image
# resized = cv2.resize(im, dim, interpolation=cv2.INTER_AREA)
#
# print('Resized Dimensions : ', resized.shape)
#
# cv2.imshow("Resized image", resized)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
im = cv2.imread(args["image"])
rotated = imutils.rotate(im, 180)
cv2.imshow("Rotated", rotated)
cv2.waitKey()
cv2.destroyAllWindows()
dir = args["image"]
cv2.imwrite(dir, rotated)