Created
July 17, 2012 11:09
-
-
Save yuyay/3128784 to your computer and use it in GitHub Desktop.
split an image into 6 small images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import os | |
import cv2 | |
row = 1882 #縦 | |
col = 1913 #横 | |
point = [(195, 133), (2073, 133), (3948, 133), | |
(200, 2035), (2072, 2035), (3938, 2035)] # | |
for files in os.listdir('testSet'): | |
print files | |
input_img = cv2.imread('testSet/' + files) | |
for num, p in enumerate(point): | |
dst_img = input_img[p[0]:p[0] + row, p[1]:p[1] + col] #yoko,tate | |
#dst_img = cv2.resize(dst_img, (dst_img.shape[1]/6, dst_img.shape[0]/6)) #リサイズ | |
cv2.imwrite('out/' + files.rstrip('.jpg') + '_' + str(num + 1) + '.jpg', dst_img) | |
#cv2.imshow('houghlines', dst_img) | |
#cv2.waitKey(0) | |
#cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment