def _filter_image(self, image): _, thresh = cv2.threshold(image, 200, 255, cv2.THRESH_BINARY) opened = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, (5, 5), iterations=3) return cv2.bitwise_not(opened)