python opencv 画出二值化图片轮廓具体代码
使用OpenCV函数cv2.threshold()可以实现二值化图片轮廓,具体代码如下:import cv2image = cv2.imread('image.jpg')gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)ret, thresh = cv2.threshold(gray, 10, 255, cv2.THRESH_BINARY)cont...
·
使用OpenCV函数cv2.threshold()可以实现二值化图片轮廓,具体代码如下:import cv2 image = cv2.imread('image.jpg') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) ret, thresh = cv2.threshold(gray, 10, 255, cv2.THRESH_BINARY) contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) cv2.drawContours
更多推荐
所有评论(0)