def PrepareImage(image):
"""Converts color image to black and white"""
# work on gray scale
bw = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
# remove noise, preserve edges
bw = cv2.bilateralFilter(bw, 9, 75, 75)
# binary threshold
bw = cv2.adaptiveThreshold(bw, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY, 11, 2)
return bw
评论列表
文章目录