-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-crop.py
35 lines (28 loc) · 866 Bytes
/
test-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
32
33
34
35
import cv2
import os
import numpy as np
from matplotlib import pyplot as plt
import glob
import ntpath
FILE_PATTERN = '/home/addo/dev/personal/cbd/images/*.png'
IMAGE_WIDTH = 300
IMAGE_HEIGHT = 75
files = glob.glob(FILE_PATTERN)
titles = []
images = []
for f in files:
filename = ntpath.basename(f)
img = cv2.imread(f,0)
crop_img = img[10: 70, 55:250]
titles.append(filename)
images.append(crop_img)
transformed = f.replace('images', 'images/transformed')
cv2.imwrite(transformed, crop_img)
# img = cv2.imread(file_name,0)
# titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']
# images = [crop_img, thresh1, thresh2, thresh3, thresh4, thresh5]
for i in xrange(len(files)):
plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')
plt.title(titles[i])
plt.xticks([]),plt.yticks([])
# plt.show()