From b19b0bfb07754921fd611bd4d84b9e7a9222e7a5 Mon Sep 17 00:00:00 2001 From: Brent Schroeter Date: Thu, 15 Jan 2026 22:14:36 +0000 Subject: [PATCH] tune sharpness detection for sparse pages --- microqa/engine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microqa/engine.py b/microqa/engine.py index 2a285ef..2dae341 100644 --- a/microqa/engine.py +++ b/microqa/engine.py @@ -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(