def filter_image(image, canny1=5, canny2=5, show=False):
# compute the ratio of the old height to the new height, and resize it
image = imutils.resize(image, height=scale_factor, interpolation=cv2.INTER_NEAREST)
# convert the image to grayscale, blur it, and find edges in the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edged = cv2.Canny(blurred, canny1, canny2)
# show the image(s)
if show:
cv2.imshow("Edged", edged)
cv2.waitKey(0)
cv2.destroyAllWindows()
return edged
评论列表
文章目录