Loading autocnet/matcher/outlier_detector.py +4 −2 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ class SpatialSuppression(Observable): """ def __init__(self, df, domain, min_radius=1, k=250, error_k=0.1): def __init__(self, df, domain, min_radius=1.5, k=250, error_k=0.1): columns = df.columns for i in ['x', 'y', 'strength']: if i not in columns: Loading Loading @@ -182,7 +182,7 @@ class SpatialSuppression(Observable): self.k = len(self.df) result = self.df.index process = False search_space = np.linspace(self.min_radius, self.max_radius, 250) search_space = np.linspace(self.min_radius, self.max_radius, 100) cell_sizes = search_space / math.sqrt(2) min_idx = 0 max_idx = len(search_space) - 1 Loading Loading @@ -242,6 +242,7 @@ class SpatialSuppression(Observable): grid[y_min: y_max, x_min: x_max] = True # Check break conditions if self.k - self.k * self.error_k <= len(result) <= self.k + self.k * self.error_k: process = False Loading @@ -251,6 +252,7 @@ class SpatialSuppression(Observable): if max_idx == 0: warnings.warn('Unable to retrieve {} points. Consider reducing the amount of points you request(k)' .format(self.k)) process = False if min_idx == max_idx: process = False elif min_idx == mid_idx or mid_idx == max_idx: Loading autocnet/matcher/tests/test_outlier_detector.py +4 −4 Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ class TestSpatialSuppression(unittest.TestCase): df1 = pd.DataFrame(r.uniform(0,1,(500, 3)), columns=['x', 'y', 'strength']) sup1 = SpatialSuppression(df1, (1,1), k = 1) self.assertRaises(ValueError, sup1.suppress) self.assertRaises(ValueError, sup1.suppress()) df2 = pd.DataFrame(r.uniform(0,6,(500, 3)), columns=['x', 'y', 'strength']) sup2 = SpatialSuppression(df2, (6,6), k = 4) df2 = pd.DataFrame(r.uniform(0,25,(500, 3)), columns=['x', 'y', 'strength']) sup2 = SpatialSuppression(df2, (25,25), k = 25) sup2.suppress() self.assertEqual(len(df2[sup2.mask]), 4) self.assertEqual(len(df2[sup2.mask]), 25) df3 = pd.DataFrame(r.uniform(0,100,(500, 3)), columns=['x', 'y', 'strength']) sup3 = SpatialSuppression(df3, (100,100), k = 15) Loading notebooks/spatial_suppression_testing.ipynb +132 −93 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
autocnet/matcher/outlier_detector.py +4 −2 Original line number Diff line number Diff line Loading @@ -138,7 +138,7 @@ class SpatialSuppression(Observable): """ def __init__(self, df, domain, min_radius=1, k=250, error_k=0.1): def __init__(self, df, domain, min_radius=1.5, k=250, error_k=0.1): columns = df.columns for i in ['x', 'y', 'strength']: if i not in columns: Loading Loading @@ -182,7 +182,7 @@ class SpatialSuppression(Observable): self.k = len(self.df) result = self.df.index process = False search_space = np.linspace(self.min_radius, self.max_radius, 250) search_space = np.linspace(self.min_radius, self.max_radius, 100) cell_sizes = search_space / math.sqrt(2) min_idx = 0 max_idx = len(search_space) - 1 Loading Loading @@ -242,6 +242,7 @@ class SpatialSuppression(Observable): grid[y_min: y_max, x_min: x_max] = True # Check break conditions if self.k - self.k * self.error_k <= len(result) <= self.k + self.k * self.error_k: process = False Loading @@ -251,6 +252,7 @@ class SpatialSuppression(Observable): if max_idx == 0: warnings.warn('Unable to retrieve {} points. Consider reducing the amount of points you request(k)' .format(self.k)) process = False if min_idx == max_idx: process = False elif min_idx == mid_idx or mid_idx == max_idx: Loading
autocnet/matcher/tests/test_outlier_detector.py +4 −4 Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ class TestSpatialSuppression(unittest.TestCase): df1 = pd.DataFrame(r.uniform(0,1,(500, 3)), columns=['x', 'y', 'strength']) sup1 = SpatialSuppression(df1, (1,1), k = 1) self.assertRaises(ValueError, sup1.suppress) self.assertRaises(ValueError, sup1.suppress()) df2 = pd.DataFrame(r.uniform(0,6,(500, 3)), columns=['x', 'y', 'strength']) sup2 = SpatialSuppression(df2, (6,6), k = 4) df2 = pd.DataFrame(r.uniform(0,25,(500, 3)), columns=['x', 'y', 'strength']) sup2 = SpatialSuppression(df2, (25,25), k = 25) sup2.suppress() self.assertEqual(len(df2[sup2.mask]), 4) self.assertEqual(len(df2[sup2.mask]), 25) df3 = pd.DataFrame(r.uniform(0,100,(500, 3)), columns=['x', 'y', 'strength']) sup3 = SpatialSuppression(df3, (100,100), k = 15) Loading
notebooks/spatial_suppression_testing.ipynb +132 −93 File changed.Preview size limit exceeded, changes collapsed. Show changes