Skip to content

Commit

Permalink
shapely 2.x does not reverse coordinate order on offset
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Nov 21, 2024
1 parent c385901 commit 5499833
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions kraken/lib/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,10 @@ def calculate_polygonal_environment(im: Image.Image = None,
line = np.array(line.coords, dtype=float)
offset_line = np.array(offset_line.coords, dtype=float)

# parallel_offset on the right reverses the coordinate order
if not topline:
offset_line = offset_line[::-1]
# calculate magnitude-weighted average direction vector
lengths = np.linalg.norm(np.diff(line.T), axis=0)
p_dir = np.mean(np.diff(line.T) * lengths/lengths.sum(), axis=1)
p_dir = (p_dir.T / np.sqrt(np.sum(p_dir**2, axis=-1)))

env_up, env_bottom = _calc_roi(line, bounds, baselines[:idx] + baselines[idx+1:], suppl_obj, p_dir)

polygons.append(_extract_patch(env_up,
Expand Down

0 comments on commit 5499833

Please sign in to comment.