diff --git a/solar_limb_detection/detection.py b/solar_limb_detection/detection.py index bd9a498d44405b21411a9e616233f871f8893b23..6f4056c3fb4f2aef5a8c30e449ee9dd717cdb111 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)