You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
681 B

# coding=gbk
import cv2
import numpy as np
def change1(filepath):#¸¯Ê´
pic = cv2.imread(filepath + 'image1.png')
src = cv2.imread(pic, cv2.IMREAD_UNCHANGED)
kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (5, 5))
erosion = cv2.erode(src, kernel)
cv2.imwrite(filepath + 'out.png', erosion)
def change2(filepath):#ÅòÕÍ
pic = cv2.imread(filepath + 'image1.png')
src = cv2.imread(pic, cv2.IMREAD_UNCHANGED)
kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (5, 5))
dilation = cv2.dilate(src, kernel)
cv2.imwrite(filepath + 'out.png', dilation)
if __name__ == '__main__':
filepath = 'pic/'
change1(filepath)
change2(filepath)