欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

图像处理-图像边缘处理

发布时间:2023/12/20 编程问答 31 豆豆
生活随笔 收集整理的这篇文章主要介绍了 图像处理-图像边缘处理 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

(考完六级补上)

1、Sobel算子

2、Laplacian算子

3、Canny算子

edge = cv2.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient ]]])
  • 参数一:需要处理的图像
  • 参数二:最小阈值MinThresh
  • 参数三:最大阈值MaxThresh
    介于MinThresh与MaxThresh之间的被识别为边界

4、运行结果

4.1 sobel

4.2 Laplacian

5、完整代码

def EdgeProcess(image):Result1_x = cv.Sobel(image,ddepth=-1,dx=1,dy=0)Result1_y = cv.Sobel(image,ddepth=-1,dx=0,dy=1)#x方向一阶边缘SobelResult_x = cv.convertScaleAbs(Result1_x)#y方向一阶边缘SobelResult_y = cv.convertScaleAbs(Result1_y)#整幅图像一阶边缘SobelResult_xy = cv.bitwise_or(SobelResult_x,SobelResult_y)#SobelResult_xy 是三通道图像SobelResult_Result = cv.hconcat((SobelResult_x,SobelResult_y,SobelResult_xy))cv.imshow("SobelResult",SobelResult_Result)cv.waitKey()#拉普拉斯算子Result2 = cv.Laplacian(image,ddepth=-1,ksize=3)LaplacianResult = cv.convertScaleAbs(Result2)cv.imshow("Laplacian",LaplacianResult)cv.waitKey()return;

总结

以上是生活随笔为你收集整理的图像处理-图像边缘处理的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。