def _extraction_iterator_corners(image, use_local_thresholding=False, apply_gaussian=False, n=5):
# If the image is too small, then double its scale until big enough.
img = image
while max(img.shape) < 500:
img = resize(img, np.array(img.shape) * 2)
if apply_gaussian:
img = gaussian_filter(image, (3.0, 3.0))
for corner_points in iter_blob_extremes(img, n=n):
try:
warped_image = geometry.warp_image_by_corner_points_projection(corner_points, img)
sudoku, bin_image = geometry.split_image_into_sudoku_pieces_adaptive_global(
warped_image, otsu_local=use_local_thresholding, apply_gaussian=apply_gaussian)
except SudokuExtractError:
# Try next blob.
pass
except Exception as e:
raise
else:
yield sudoku, bin_image
评论列表
文章目录