def find_max_contour(threshed_image, filter_func = None, accuracy_percent_with_perimeter=0.0001): contours = Image.find_contours( threshed_image, filter_func, accuracy_percent_with_perimeter) # from picture_sudoku.cv2_helpers.display import Display # Display.contours(threshed_image, contours) if len(contours) == 0: return None contour_area_arr = [cv2.contourArea(i) for i in contours] max_contour = contours[contour_area_arr.index(max(contour_area_arr))] return max_contour