Spaces:
Runtime error
Runtime error
File size: 1,443 Bytes
7e42a78 |
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 39 40 41 42 43 44 45 46 |
def cropping(image, filename):
#Left Top Crop
crop = image[:96, :96]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'leftTop' + '.png', crop)
#Center Top Crop
crop = image[:96, 16:112]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'centerTop' + '.png', crop)
#Right Top Crop
crop = image[:96, 32:]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'rightTop' + '.png', crop)
#Left Center Crop
crop = image[16:112, :96]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'leftCenter' + '.png', crop)
#Center Center Crop
crop = image[16:112, 16:112]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'centerCenter' + '.png', crop)
#Right Center Crop
crop = image[16:112, 32:]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'rightCenter' + '.png', crop)
#Left Bottom Crop
crop = image[32:, :96]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'leftBottom' + '.png', crop)
#Center Bottom Crop
crop = image[32:, 16:112]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'centerBottom' + '.png', crop)
#Right Bottom Crop
crop = image[32:, 32:]
crop = cv2.resize(crop, (128, 128))
cv2.imwrite(filename[:-4] + 'rightBottom' + '.png', crop) |