mirror of
https://github.com/ciromattia/kcc
synced 2026-02-21 11:39:08 +00:00
fix cropping divide by zero (#1220)
This commit is contained in:
@@ -160,6 +160,8 @@ def ignore_pixels_near_edge(bw_img):
|
|||||||
for box in edge_bbox:
|
for box in edge_bbox:
|
||||||
edge = bw_img.crop(box)
|
edge = bw_img.crop(box)
|
||||||
h = edge.histogram()
|
h = edge.histogram()
|
||||||
|
if not edge.height or not edge.width:
|
||||||
|
continue
|
||||||
imperfections = h[255] / (edge.height * edge.width)
|
imperfections = h[255] / (edge.height * edge.width)
|
||||||
if imperfections > 0 and imperfections < .02:
|
if imperfections > 0 and imperfections < .02:
|
||||||
bw_img.paste(im=0, box=box)
|
bw_img.paste(im=0, box=box)
|
||||||
|
|||||||
Reference in New Issue
Block a user