美文网首页
08边缘检测1

08边缘检测1

作者: 犬夜叉写作业 | 来源:发表于2019-07-14 15:36 被阅读0次

    边缘检测实则为图片的卷积运算
    canny边缘检测:
    第一步:转换为灰度图
    第二步:高斯滤波
    第三步:调用canny方法

    import cv2
    import numpy as np
    import random
    img = cv2.imread('image0.jpg',1)
    imgInfo = img.shape
    height = imgInfo[0]
    width = imgInfo[1]
    cv2.imshow('src',img)
    
    #canny 1 gray 2 高斯 3 canny 
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    imgG = cv2.GaussianBlur(gray,(3,3),0)  #高斯滤波
    dst = cv2.Canny(img,50,50) #(图片,图片的门限) ;如果图片经过卷积运算后大于图片的门限,则认为该点为边缘点
    cv2.imshow('dst',dst)
    cv2.waitKey(0)
    
    image.png

    相关文章

      网友评论

          本文标题:08边缘检测1

          本文链接:https://www.haomeiwen.com/subject/daabkctx.html