一、图像的腐蚀处理
1、原图
img = cv2.imread(r"C:\Users\admin\Desktop\hb.jpg")
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
首先原图周围又很多白色直线
2、进行腐蚀处理
使用的方法是
cv2.erode(img,kernel,iterations=1)
img:原图
kenrnel:核的大小
iterations:迭代次数
img = cv2.imread(r"C:\Users\admin\Desktop\hb.jpg")
kernel = np.ones((3, 3), np.uint8)
erosion = cv2.erode(img,kernel,iterations=1)
cv2.imshow('img', erosion)
cv2.waitKey(0)
cv2.destroyAllWindows()
二、图像的膨胀处理
1、原图
img = cv2.imread(r"C:\Users\admin\Desktop\hb.jpg")
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
2、进行膨胀处理
使用的方法是
cv2.dilate(img,kernel,iterations=1)
img:原图
kenrnel:核的大小
iterations:迭代次数
kernel = np.ones((3, 3), np.uint8)
dilate = cv2.dilate(img,kernel,iterations=1)
cv2.imshow('img', dilate)
cv2.waitKey(0)
cv2.destroyAllWindows()
会发现线条照原图变粗