场景
对大米预处理之后的二值图像做开运算再做canny边缘检测。
python代码:
1 # kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3)) # 椭圆的核 2 3 kernel = np.ones((3,3),np.uint8) # 去除白色噪点,形态学开运算,3x3线性核 4 5 opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations = 2) 6 7 cv2.imshow("opening",opening) 8 9 10 11 edges = cv2.Canny(opening,50,200) 12 13 cv2.imshow("edges",edges)