-
Notifications
You must be signed in to change notification settings - Fork 0
/
crop.py
31 lines (24 loc) · 806 Bytes
/
crop.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
import cv2
import sys
import numpy as np
def main(argv):
# load the image
image = cv2.imread(argv[1])
# crop the image
cropped_image = image[60:754-70:, :]
cropped_image = cropped_image[:, 240:1536-200]
new_image = np.concatenate(
(cropped_image[:, :160], cropped_image[:, 150*2:160*3]), axis=1)
new_image2 = np.concatenate(
(new_image, cropped_image[:, 155*4:160*5]), axis=1)
new_image3 = np.concatenate((new_image2, cropped_image[:, 155*6:]), axis=1)
# show the image
cv2.imshow('image', new_image3)
# write the image
cv2.imwrite('.\Presentation_Report_Images\{}_cropped.png'.format(
argv[1]), new_image3)
# wait for a keypress
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == '__main__':
main(sys.argv)