tune sharpness detection for sparse pages

This commit is contained in:
Brent Schroeter 2026-01-15 22:14:36 +00:00
parent df786f103f
commit b19b0bfb07

View file

@ -157,7 +157,9 @@ def analyze_sharpness(im: Image.Image) -> float:
# results across documents. We've had much more luck with a direct gradient
# computation based on https://stackoverflow.com/a/26014796.
grad_y, grad_x = np.gradient(np.asarray(im))
return float(np.clip(np.quantile(np.sqrt(grad_x**2 + grad_y**2), 0.99) / 255, 0, 1))
return float(
np.clip(np.quantile(np.sqrt(grad_x**2 + grad_y**2), 0.9999) / 255, 0, 1)
)
def compute_ocr(