tune sharpness detection for sparse pages
This commit is contained in:
parent
df786f103f
commit
b19b0bfb07
1 changed files with 3 additions and 1 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue