OpenCV的一些API的使用

本文章会陆续记录一些OpenCV的API方法

# 高斯模糊
imgBlur = cv2.GaussianBlur(imgGray, (7, 7), 0)
# 边缘检测
imgCanny = cv2.Canny(img, 100, 100)
# 数值改大之后,线条少一些了
imgCanny = cv2.Canny(img, 150, 200)

image    image   image    image

# uint8 是指 0~255
kernel = np.ones((5, 5), np.uint8)

# 膨胀,迭代从1变成5,就变成了有右图的样子
imgDilation = cv2.dilate(imgCanny, kernel=kernel, iterations=1)
# 腐蚀
imgErode = cv2.erode(imgDilation, kernel=kernel, iterations=1)

dilate 膨胀

image   image   image

 为什么要把图像弄模糊呢?

 

posted @ 2025-09-20 21:18  SpongeBob~  阅读(6)  评论(0)    收藏  举报