hytos / minorTools / deleteBorder.py @ 0d8516d2
이력 | 보기 | 이력해설 | 다운로드 (692 Bytes)
1 |
import numpy as np |
---|---|
2 |
import cv2, os |
3 |
|
4 |
rootPath = 'C:\\Users\\HA\Desktop\\ID2\\drawings'
|
5 |
imgList = os.listdir(rootPath) |
6 |
|
7 |
startX, startY, endX, endY = [7376], \
|
8 |
[5830], \
|
9 |
[9246], \
|
10 |
[6733]
|
11 |
|
12 |
print('start')
|
13 |
|
14 |
for imgPath in imgList: |
15 |
fullPath = os.path.join(rootPath, imgPath) |
16 |
|
17 |
img = cv2.imread(fullPath, cv2.IMREAD_GRAYSCALE) |
18 |
|
19 |
for i in range(len(startX)): |
20 |
img = cv2.rectangle(img, (startX[i], startY[i]), (endX[i], endY[i]), 255, -1) |
21 |
|
22 |
originPath = os.path.splitext(fullPath) |
23 |
|
24 |
newPath = originPath[0] + originPath[1] |
25 |
|
26 |
cv2.imwrite(newPath, img) |
27 |
|
28 |
print('finished')
|