#模糊算子#高斯模糊函数 (5, 5)表示高斯矩阵的长与宽都是5,标准差取0
cv2.GaussianBlur(img,(5,5),0)#中值滤波,相当于将blurKsize= 3 相当9个值进行排序,取中值作为当前值return img
cv2.medianBlur(img,blurKsize)#边缘检测算子
cv2.Laplacian(src_img,cv2.CV_8U,dst_img,ksize)#卷积操作
cv.filter2D(src, ddepth, kernel[, dst[, anchor[, delta[, borderType]]]])#for example import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('opencv_logo.png')
kernel = np.ones((5,5),np.float32)/25#-1 mean same depth
dst = cv.filter2D(img,-1,kernel)
plt.subplot(121),plt.imshow(img),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(dst),plt.title('Averaging')
plt.xticks([]), plt.yticks([])
plt.show()#canny算子
edges = cv.Canny( image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]])[详见链接](https://docs.opencv.org/master/da/d22/tutorial_py_canny.html)#轮廓检测 first one is source image, second is contour retrieval mode, third is contour approximation method
contours, hierarchy = cv.findContours( image, mode, method[, contours[, hierarchy[, offset]]])#画出轮廓 Its first argument is source image, second argument is the contours which should be passed as a Python list, third argument is index of contours (useful when drawing individual contour. To draw all contours, pass -1) and remaining arguments are color, thickness etc
image = cv.drawContours( image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]])[详见链接](https://docs.opencv.org/master/d4/d73/tutorial_py_contours_begin.html)