实验:

 1 # Writer : wojianxinygcl@163.com
 2 # Date   : 2020.3.22
 3 import cv2 as cv
 4 import numpy as np
 5 
 6 image = cv.imread("../bird.png")
 7 gray = cv.cvtColor(image,cv.COLOR_RGB2GRAY)
 8 
 9 # 80以下为0,210以上为255,中间使用 8-近邻算法确定像素值
10 edges = cv.Canny(gray,80,210)
11 
12 # 使用闭运算连接中断的图像前景,迭代运算三次
13 result = cv.morphologyEx(edges,cv.MORPH_CLOSE,kernel=(3,3),iterations=3)
14 
15 cv.imshow('After Canny',edges)
16 cv.imshow('After Morphology Close',result)
17 cv.waitKey(0)
18 cv.destroyAllWindows()

 


实验结果:

Canny算法提取图像边缘后,用闭运算连接断掉的线
Canny算法结果(左)、Canny算法后闭运算结果(右) ↑

    如果你觉得对你有帮助,帮忙点赞哦!

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2021-12-15
  • 2021-11-16
  • 2022-12-23
  • 2021-09-11
  • 2021-09-27
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-06-12
  • 2021-05-24
  • 2022-12-23
相关资源
相似解决方案