Skip to content

Commit

Permalink
Filter out very small regions in segmenter
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Mar 6, 2024
1 parent feeecc9 commit 4248ca0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kraken/lib/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4248ca0

Please sign in to comment.