프로젝트

일반

사용자정보

통계
| 개정판:

hytos / minorTools / symbolKenelChanger.py @ f37c5383

이력 | 보기 | 이력해설 | 다운로드 (914 Bytes)

1 cf815388 esham21
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()
클립보드 이미지 추가 (최대 크기: 500 MB)