Canny边缘提取

1.边缘提取

def edge_demo(image):

    blurred = cv.GaussianBlur(image, (3,3),0)

    gray =cv.cvtColor(blurred,cv.COLOR_BGR2GRAY)

    #x梯度

    xgrad = cv.Sobel(gray,cv.CV_16SC1,1,0)

    #y梯度

    ygrad = cv.Sobel(gray,cv.CV_16SC1,0,1)

    #edge

    #edge_output = cv.Canny(xgrad, ygrad, 50,150)

    edge_output = cv.Canny(gray,50,150)

    cv.imshow("edge_demo",edge_output)

    dst = cv.bitwise_and(image, image, mask=edge_output)

    cv.imshow("color edge",dst)

你可能感兴趣的:(语法基础)