def process_frame_for_game_play(frame):
"""Assumes a grayscale frame"""
histogram = skimage.exposure.histogram(frame[40:])
if np.unique(histogram[0]).size < 3:
return None
max_indices = np.argpartition(histogram[0], -3)[-3:]
for index in sorted(max_indices)[:2]:
frame[frame == index] = 0
threshold = skimage.filters.threshold_otsu(frame[40:])
bw_frame = frame > threshold
return bw_frame
评论列表
文章目录