实验:
# Writer : wojianxinygcl@163.com
# Date : 2020.3.22
import cv2 as cv
import numpy as np
image = cv.imread("../bird.png")
gray = cv.cvtColor(image,cv.COLOR_RGB2GRAY)
# 80以下为0,210以上为255,中间使用 8-近邻算法确定像素值
edges = cv.Canny(gray,80,210)
# 使用闭运算连接中断的图像前景,迭代运算三次
result = cv.morphologyEx(edges,cv.MORPH_CLOSE,kernel=(3,3),iterations=3)
cv.imshow('After Canny',edges)
cv.imshow('After Morphology Close',result)
cv.waitKey(0)
cv.destroyAllWindows()
实验结果:
Canny算法结果(左)、Canny算法后闭运算结果(右) ↑
如果你觉得对你有帮助,帮忙点赞哦!