1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-25 22:47:28 +00:00

fix cropping divide by zero (#1220)

This commit is contained in:
Alex Xu
2026-01-20 20:47:56 -08:00
committed by GitHub
parent 4baca03214
commit f5fd2bb7fe

View File

@@ -160,6 +160,8 @@ def ignore_pixels_near_edge(bw_img):
for box in edge_bbox:
edge = bw_img.crop(box)
h = edge.histogram()
if not edge.height or not edge.width:
continue
imperfections = h[255] / (edge.height * edge.width)
if imperfections > 0 and imperfections < .02:
bw_img.paste(im=0, box=box)