hytos / minorTools / deleteBorder.py @ 81dc4ad2
이력 | 보기 | 이력해설 | 다운로드 (721 Bytes)
1 |
import numpy as np |
---|---|
2 |
import cv2, os |
3 |
|
4 |
rootPath = 'X:\CPChem\drawings'
|
5 |
imgList = os.listdir(rootPath) |
6 |
|
7 |
startX, startY, endX, endY = [417, 3727, 7723], \ |
8 |
[5815, 5534, 5262], \ |
9 |
[9374, 9374, 9374], \ |
10 |
[6096, 6096, 6096] |
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')
|