一.Sobel算子
计算图像x方向边缘
sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=3)
sobelx = cv2.convertScaleAbs(sobelx)
cv_show("sobelx",sobelx)
计算图像y方向边缘
sobely = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=3)
sobely = cv2.convertScaleAbs(sobely)
cv_show("sobely",sobely)
合并
sobel_demo = cv2.assWeighted(sobelx,,0.5,0.5)
cv_show("sobel_demo",sobel_demo)
Scharr算子
Scharrx = cv2.Scharr(img,cv2.CV_64F,1,0)
Scharry = cv2.Scharr(img,cv2.CV_64F,0,1)
Scharrx = cv2.convertScaleAbs(sobelx)
Scharry = cv2.convertScaleAbs(sobely)
Scharr_demo = cv2.addWeighted(sobelx,0.5,sobely,0.5,0.5)
二.Laplacian算子
laplacian = cv2.Laplacian(img,cv2.CV_64F)
laplacian = cv2.converScaleAbs(laplacian)
三.Canny边缘检测
、
v1=cv2.Canny(peppa,80,150)
v2=cv2.Canny(peppa,50,100)
cv2.imshow("v1",v1)
cv2.imshow("v2",v2)
cv2.waitKey()
cv2.destroyAllWindows()