From 4248ca000f76b25816446c42e66c26bdbfacafa6 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Wed, 6 Mar 2024 17:26:32 +0100 Subject: [PATCH] Filter out very small regions in segmenter --- kraken/lib/segmentation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kraken/lib/segmentation.py b/kraken/lib/segmentation.py index 87870562a..abff7abd5 100644 --- a/kraken/lib/segmentation.py +++ b/kraken/lib/segmentation.py @@ -352,10 +352,13 @@ def vectorize_regions(im: np.ndarray, threshold: float = 0.5): [[x0, y0, ... xn, yn], [xm, ym, ..., xk, yk], ... ] A list of lists containing the region polygons. """ + print(f'shape: {im.shape} {im.max()}') bin = im > threshold labelled = label(bin) boundaries = [] for x in regionprops(labelled): + if x.area < 32: + continue boundary = boundary_tracing(x) if len(boundary) > 2: boundaries.append(geom.Polygon(boundary))