Skip to content

Commit

Permalink
Move region polygon simplification to later point in vectorization
Browse files Browse the repository at this point in the history
partially resolves #319
  • Loading branch information
mittagessen committed Aug 24, 2022
1 parent 7c00184 commit 262c00d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kraken/lib/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ def vectorize_regions(im: np.ndarray, threshold: float = 0.5):
for x in regionprops(labelled):
boundary = boundary_tracing(x)
if len(boundary) > 2:
boundaries.append(geom.Polygon(boundary).simplify(10))
boundaries.append(geom.Polygon(boundary))
# merge regions that overlap after simplification

This comment has been minimized.

Copy link
@stweil

stweil Aug 24, 2022

Contributor

I think this comment needs an update, too.

boundaries = unary_union(boundaries)
if boundaries.type == 'Polygon':
boundaries = [boundaries.boundary]
boundaries = [boundaries.boundary.simplify(10)]
else:
boundaries = [x.boundary for x in unary_union(boundaries)]
boundaries = [x.boundary.simplify(10) for x in unary_union(boundaries)]
return [np.array(x.coords, dtype=np.uint)[:, [1, 0]].tolist() for x in boundaries]


Expand Down

0 comments on commit 262c00d

Please sign in to comment.