From 3461bda120ace2325faaf7b96b45b4a39edd28b0 Mon Sep 17 00:00:00 2001
From: Jay Paul Morgan <jaymiles17@gmail.com>
Date: Fri, 16 Jun 2023 13:24:25 +0100
Subject: [PATCH] Improve the detection of limb points

---
 solar_limb_detection/detection.py | 33 +++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/solar_limb_detection/detection.py b/solar_limb_detection/detection.py
index bd9a498..6f4056c 100644
--- a/solar_limb_detection/detection.py
+++ b/solar_limb_detection/detection.py
@@ -50,30 +50,33 @@ class CircleFitter(torch.nn.Module):
 
 def find_anchors(smap: sunpy.map.GenericMap) -> torch.Tensor:
     x,y = smap.shape
-    xs = np.linspace(x//4, x-x//4, 69, dtype=int)
-    ys = np.linspace(y//4, y-y//4, 69, dtype=int)
+    inter = 3
+    xs = np.linspace(x//inter, x-x//inter, 69, dtype=int)
+    ys = np.linspace(y//inter, y-y//inter, 69, dtype=int)
 
     k = np.array([-1, 0, +1]).reshape(1, 3)
     dy = cv2.filter2D(filters.gaussian(smap, 7), -1, k.reshape(-1, 1))
     dx = cv2.filter2D(filters.gaussian(smap, 7), -1, k)
-
     points = []
-    for xi in xs:
-        # bottom profile
-        point = np.argmin(dy[y-(y//4):, xi])
-        points.append((xi, y-y//4+point))
     for yi in ys:
-        # right profile
-        point = np.argmin(dx[yi, x-x//4:])
-        points.append((x-x//4+point, yi))
+        # bottom profile
+        point = np.argmin(dy[x-x//inter:, yi])
+        points.append((yi, x-x//inter+point))
+        
     for xi in xs:
-        # top profile
-        point = np.argmax(dy[:y//4, xi])
-        points.append((xi, point))
+        # right profile
+        point = np.argmin(dx[xi, y-y//inter:])
+        points.append((y-y//inter+point, xi))
+    
     for yi in ys:
+        # top profile
+        point = np.argmax(dy[:x//inter, yi])
+        points.append((yi, point))
+    
+    for xi in xs:
         # left profile
-        point = np.argmax(dx[yi,:y//3])
-        points.append((point, yi))
+        point = np.argmax(dx[xi,:y//inter])
+        points.append((point, xi))
 
     return torch.Tensor(points)
 
-- 
GitLab