def adaptive_threshold(image, above_thresh_assigned=255, kind='mean', cell_size=35, c_param=17,
thresh_style=cv.THRESH_BINARY_INV):
'''
:param kind: specify adaptive method, whether 'mean' or 'gaussian'.
:param cell_size: n for the region size (n x n).
:param c_param: subtraction constant.
:return: a binary version of the input image.
'''
if kind == 'mean':
method = cv.ADAPTIVE_THRESH_MEAN_C
elif kind == 'gaussian':
method = cv.ADAPTIVE_THRESH_GAUSSIAN_C
else:
raise ValueError('Unknown adaptive threshold method.')
return cv.adaptiveThreshold(image, above_thresh_assigned, method, thresh_style, cell_size, c_param)
评论列表
文章目录