zhiqingstudy

Be a young person with knowledge and content

Canny is called the ultimate method of edge detection, because it is very simple compared with Sobel, Schell and Laplace filtering. On the one hand, Canny handles edges very carefully and has good results. In addition, Canny is also very simple, and only needs to call an api.

How did Canny achieve such efficiency? In brief, it can be summarized as the following four steps:
1. Use 5 * 5 Gaussian filter to eliminate noise
2. Call Sobel to calculate the direction of image gradient (0 °/45 °/90 °/135 °)
3. Take local maximum value in 4 directions
4. Threshold calculation

Canny's api:
Canny(img,minVal,maxVal,...)
Img: specific image
MinVal: What is the minimum threshold value? If it is less than this threshold value, it is not considered as an edge
MaxVal: What is the maximum threshold value? If it is greater than this value, it must be an edge. If it is between the minimum value and the maximum value, it should be calculated
import cv2
import numpy as np


# 导入一张图
img=cv2.imread('你的图片')
# canny边缘检测
dst=cv2.Canny(img,100,220)

# 显示图片
cv2.imshow('img',img)
cv2.imshow('dst',dst)
cv2.waitKey(0)
comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号