|
a |
|
b/cropping.py |
|
|
1 |
def cropping(image, filename): |
|
|
2 |
|
|
|
3 |
#Left Top Crop |
|
|
4 |
crop = image[:96, :96] |
|
|
5 |
crop = cv2.resize(crop, (128, 128)) |
|
|
6 |
cv2.imwrite(filename[:-4] + 'leftTop' + '.png', crop) |
|
|
7 |
|
|
|
8 |
#Center Top Crop |
|
|
9 |
crop = image[:96, 16:112] |
|
|
10 |
crop = cv2.resize(crop, (128, 128)) |
|
|
11 |
cv2.imwrite(filename[:-4] + 'centerTop' + '.png', crop) |
|
|
12 |
|
|
|
13 |
#Right Top Crop |
|
|
14 |
crop = image[:96, 32:] |
|
|
15 |
crop = cv2.resize(crop, (128, 128)) |
|
|
16 |
cv2.imwrite(filename[:-4] + 'rightTop' + '.png', crop) |
|
|
17 |
|
|
|
18 |
#Left Center Crop |
|
|
19 |
crop = image[16:112, :96] |
|
|
20 |
crop = cv2.resize(crop, (128, 128)) |
|
|
21 |
cv2.imwrite(filename[:-4] + 'leftCenter' + '.png', crop) |
|
|
22 |
|
|
|
23 |
#Center Center Crop |
|
|
24 |
crop = image[16:112, 16:112] |
|
|
25 |
crop = cv2.resize(crop, (128, 128)) |
|
|
26 |
cv2.imwrite(filename[:-4] + 'centerCenter' + '.png', crop) |
|
|
27 |
|
|
|
28 |
#Right Center Crop |
|
|
29 |
crop = image[16:112, 32:] |
|
|
30 |
crop = cv2.resize(crop, (128, 128)) |
|
|
31 |
cv2.imwrite(filename[:-4] + 'rightCenter' + '.png', crop) |
|
|
32 |
|
|
|
33 |
#Left Bottom Crop |
|
|
34 |
crop = image[32:, :96] |
|
|
35 |
crop = cv2.resize(crop, (128, 128)) |
|
|
36 |
cv2.imwrite(filename[:-4] + 'leftBottom' + '.png', crop) |
|
|
37 |
|
|
|
38 |
#Center Bottom Crop |
|
|
39 |
crop = image[32:, 16:112] |
|
|
40 |
crop = cv2.resize(crop, (128, 128)) |
|
|
41 |
cv2.imwrite(filename[:-4] + 'centerBottom' + '.png', crop) |
|
|
42 |
|
|
|
43 |
#Right Bottom Crop |
|
|
44 |
crop = image[32:, 32:] |
|
|
45 |
crop = cv2.resize(crop, (128, 128)) |
|
|
46 |
cv2.imwrite(filename[:-4] + 'rightBottom' + '.png', crop) |