hytos / minorTools / symbolKenelChanger.py @ 954de090
이력 | 보기 | 이력해설 | 다운로드 (914 Bytes)
1 |
import numpy as np |
---|---|
2 |
import cv2, os |
3 |
|
4 |
rootPath = 'C:\id2 project\SECL PJT_20190902_ori\image'
|
5 |
rootList = os.listdir(rootPath) |
6 |
|
7 |
for folder in rootList: |
8 |
path = os.path.join(rootPath, folder) |
9 |
imgList = os.listdir(path) |
10 |
|
11 |
for imgPath in imgList: |
12 |
fullPath = os.path.join(path, imgPath) |
13 |
|
14 |
img = cv2.imread(fullPath, cv2.IMREAD_GRAYSCALE) |
15 |
|
16 |
kernel = np.ones((3,3), np.uint8) |
17 |
|
18 |
#e = cv2.erode(img, kernel,iterations=1)
|
19 |
#d = cv2.dilate(img, kernel,iterations=1)
|
20 |
|
21 |
height,width = img.shape[0], img.shape[1] |
22 |
|
23 |
#cv2.imshow('e',e)
|
24 |
#cv2.imshow('d',d)
|
25 |
|
26 |
new = np.ones((height + 10,width + 10), np.uint8) * 255 |
27 |
|
28 |
new[5:5+height, 5:5+width] = img |
29 |
|
30 |
e = cv2.erode(new, kernel,iterations=1)
|
31 |
|
32 |
#cv2.imshow('e',e)
|
33 |
cv2.imwrite(fullPath, e) |
34 |
|
35 |
#cv2.imshow('n',new)
|
36 |
|
37 |
#cv2.waitKey(0)
|
38 |
#cv2.destroyAllWindows()
|
39 |
|