hytos / minorTools / deleteBorder.py @ 1f75c4f0
이력 | 보기 | 이력해설 | 다운로드 (692 Bytes)
1 | 8282b630 | esham21 | import numpy as np |
---|---|---|---|
2 | import cv2, os |
||
3 | |||
4 | 2be622f5 | esham21 | rootPath = 'C:\\Users\\HA\Desktop\\ID2\\drawings'
|
5 | 8282b630 | esham21 | imgList = os.listdir(rootPath) |
6 | |||
7 | 2be622f5 | esham21 | startX, startY, endX, endY = [7376], \
|
8 | [5830], \
|
||
9 | [9246], \
|
||
10 | [6733]
|
||
11 | 8282b630 | esham21 | |
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 | 7dba979e | esham21 | for i in range(len(startX)): |
20 | img = cv2.rectangle(img, (startX[i], startY[i]), (endX[i], endY[i]), 255, -1) |
||
21 | 8282b630 | esham21 | |
22 | originPath = os.path.splitext(fullPath) |
||
23 | |||
24 | 7dba979e | esham21 | newPath = originPath[0] + originPath[1] |
25 | 8282b630 | esham21 | |
26 | cv2.imwrite(newPath, img) |
||
27 | |||
28 | 7dba979e | esham21 | print('finished') |