def img_pre_treatment(file_path):
im = cv2.imread(file_path)
resize_pic=cv2.resize(im,(640,480),interpolation=cv2.INTER_CUBIC)
resize_pic = cv2.GaussianBlur(resize_pic,(5,5),0)
cv2.imwrite('static/InterceptedIMG/resize.jpg',resize_pic)
kernel = np.ones((3,3),np.uint8)
resize_pic = cv2.erode(resize_pic,kernel,iterations = 3)
resize_pic = cv2.dilate(resize_pic,kernel,iterations = 3)
cv2.imshow('image',resize_pic)
k = cv2.waitKey(0) & 0xFF
if k == 27:
cv2.destroyAllWindows()
gray = cv2.cvtColor(resize_pic,cv2.COLOR_BGR2GRAY)
ret, binary = cv2.threshold(gray,90,255,cv2.THRESH_BINARY)
cv2.imshow('image',binary)
k = cv2.waitKey(0) & 0xFF
if k == 27:
cv2.destroyAllWindows()
return resize_pic,binary
评论列表
文章目录