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.

12 lines
429 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import cv2
def erosion(image_path,ksize):
# 图像的二值化
src = cv2.imread(image_path, cv2.IMREAD_UNCHANGED)
# 使用一个交叉型结构元核心在几何中心对二值图片src进行腐蚀
ks = int(ksize)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (ks, ks))
erosion = cv2.erode(src, kernel)
cv2.imshow('result',erosion)
cv2.waitKey(0)
cv2.destroyAllWindows()