개정판 8282b630
issue #000: add image border deleter
Change-Id: Iff0c388a52954696fcc97f04952c0613f14d93c6
minorTools/deleteBorder.py | ||
---|---|---|
1 |
import numpy as np |
|
2 |
import cv2, os |
|
3 |
|
|
4 |
rootPath = 'E:\Projects\LPG\drawings_' |
|
5 |
imgList = os.listdir(rootPath) |
|
6 |
|
|
7 |
startX, startY, endX, endY = 6783, 121, 8223, 5820 |
|
8 |
|
|
9 |
print('start') |
|
10 |
|
|
11 |
for imgPath in imgList: |
|
12 |
fullPath = os.path.join(rootPath, imgPath) |
|
13 |
|
|
14 |
img = cv2.imread(fullPath, cv2.IMREAD_GRAYSCALE) |
|
15 |
|
|
16 |
img = cv2.rectangle(img, (startX, startY), (endX, endY), 255, -1) |
|
17 |
|
|
18 |
originPath = os.path.splitext(fullPath) |
|
19 |
|
|
20 |
newPath = originPath[0] + '_new' + originPath[1] |
|
21 |
|
|
22 |
cv2.imwrite(newPath, img) |
|
23 |
|
|
24 |
print('finished') |
내보내기 Unified diff