From aef6893d2a53b00d340b144495c407d58faf6a8c Mon Sep 17 00:00:00 2001 From: kwinkunks Date: Tue, 10 Oct 2023 22:24:13 +0200 Subject: [PATCH] Add comments --- gio/closure.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gio/closure.py b/gio/closure.py index a87ba6f..80f1f2c 100644 --- a/gio/closure.py +++ b/gio/closure.py @@ -120,13 +120,18 @@ def find_closures(arr: ArrayLike, # Capture all contours that are high enough. for contour in contours: + y_, x = contour.T # y_ is row *from top* of array contour = np.stack([x, y_, np.ones_like(x)*level]).T p = Polygon(contour) + + # Do various tests. if p.area < min_area: continue if not is_high(arr_, p): continue if any([p.within(c) for c in all_contours]): continue if (closure_height(arr_, contour) - level) < min_height: continue + + # What's left is a good closure. all_contours.append(p) return all_contours