Loading autocnet/graph/network.py +13 −62 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class CandidateGraph(nx.Graph): self.node_counter = 0 node_labels = {} self.node_name_map = {} self.graph_masks = {} self.graph_masks = pd.DataFrame() # the node_name is the relative path for the image for node_name, node in self.nodes_iter(data=True): Loading Loading @@ -368,15 +368,21 @@ class CandidateGraph(nx.Graph): of keys in graph_masks """ if graph_mask_keys: merged_graph_mask = self.graph_masks[graph_mask_keys].all(axis=1) edges_to_iter = merged_graph_mask[merged_graph_mask].index else: edges_to_iter = self.edges() if not isinstance(func, str): func = func.__name__ for s, d in edges_to_iter: curr_edge = self.get_edge_data(s, d) try: function = getattr(curr_edge, func) except: raise AttributeError('The passed function is not an attribute of Edge') raise AttributeError(func, ' is not an attribute of Edge') else: function(*args, **kwargs) Loading @@ -391,66 +397,12 @@ class CandidateGraph(nx.Graph): boolean mask for edges in the minimum spanning tree """ self.graph_masks = pd.DataFrame(False, index=self.edges(), columns=['mst']) graph_mask = pd.Series(False, index=self.edges()) self.graph_masks['mst'] = graph_mask mst = nx.minimum_spanning_tree(self) self.graph_masks['mst'][mst.edges()] = True def symmetry_checks(self): """ Perform a symmetry check on all edges in the graph """ for s, d, edge in self.edges_iter(data=True): edge.symmetry_check() def ratio_checks(self, clean_keys=[], **kwargs): """ Perform a ratio check on all edges in the graph """ for s, d, edge in self.edges_iter(data=True): edge.ratio_check(clean_keys=clean_keys) def compute_homographies(self, clean_keys=[], **kwargs): """ Compute homographies for all edges using identical parameters Parameters ---------- clean_keys : list Of keys in the mask dict """ for s, d, edge in self.edges_iter(data=True): edge.compute_homography(clean_keys=clean_keys, **kwargs) def compute_fundamental_matrices(self, clean_keys=[], **kwargs): """ Compute fundamental matrices for all edges using identical parameters Parameters ---------- clean_keys : list Of keys in the mask dict """ for s, d, edge in self.edges_iter(data=True): edge.compute_fundamental_matrix(clean_keys=clean_keys, **kwargs) def subpixel_register(self, clean_keys=[], threshold=0.8, upsampling=10, template_size=9, search_size=27, tiled=False, **kwargs): """ Compute subpixel offsets for all edges using identical parameters """ for s, d, edge in self.edges_iter(data=True): edge.subpixel_register(clean_keys=clean_keys, threshold=threshold, upsampling=upsampling, template_size=template_size, search_size=search_size, tiled=tiled, **kwargs) def suppress(self, clean_keys=[], func=spf.correlation, **kwargs): for s, d, e in self.edges_iter(data=True): e.suppress(clean_keys=clean_keys, func=func, **kwargs) def to_filelist(self): """ Generate a file list for the entire graph. Loading Loading @@ -503,7 +455,6 @@ class CandidateGraph(nx.Graph): : C the cleaned control network """ mask = np.zeros(len(cnet), dtype=bool) counter = 0 for i, group in cnet.groupby('pid'): Loading functional_tests/test_three_image.py +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ class TestThreeImageMatching(unittest.TestCase): for source, destination, edge in cg.edges_iter(data=True): edge.symmetry_check() edge.ratio_check(clean_keys=['symmetry'], ratio=0.99) cg.compute_homographies(clean_keys=['symmetry', 'ratio']) cg.apply_func_to_edges("compute_homography", clean_keys=['symmetry', 'ratio']) # Step: And create a C object cnet = cg.to_cnet(clean_keys=['symmetry', 'ratio', 'ransac']) Loading functional_tests/test_two_image.py +2 −2 Original line number Diff line number Diff line Loading @@ -73,14 +73,14 @@ class TestTwoImageMatching(unittest.TestCase): self.assertIn(edge.masks['ratio'].sum(), range(40, 100)) # Step: Compute the homographies and apply RANSAC cg.compute_homographies(clean_keys=['symmetry', 'ratio']) cg.apply_func_to_edges("compute_homography", clean_keys=['symmetry', 'ratio']) # Step: Compute the overlap ratio and coverage ratio for s, d, edge in cg.edges_iter(data=True): edge.coverage_ratio(clean_keys=['symmetry', 'ratio']) # Step: Compute subpixel offsets for candidate points cg.subpixel_register(clean_keys=['ransac']) cg.apply_func_to_edges("subpixel_register", clean_keys=['ransac']) # Step: And create a C object cnet = cg.to_cnet(clean_keys=['symmetry', 'ratio', 'ransac', 'subpixel']) Loading notebooks/Tutorial with Visualization.ipynb +61 −35 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
autocnet/graph/network.py +13 −62 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class CandidateGraph(nx.Graph): self.node_counter = 0 node_labels = {} self.node_name_map = {} self.graph_masks = {} self.graph_masks = pd.DataFrame() # the node_name is the relative path for the image for node_name, node in self.nodes_iter(data=True): Loading Loading @@ -368,15 +368,21 @@ class CandidateGraph(nx.Graph): of keys in graph_masks """ if graph_mask_keys: merged_graph_mask = self.graph_masks[graph_mask_keys].all(axis=1) edges_to_iter = merged_graph_mask[merged_graph_mask].index else: edges_to_iter = self.edges() if not isinstance(func, str): func = func.__name__ for s, d in edges_to_iter: curr_edge = self.get_edge_data(s, d) try: function = getattr(curr_edge, func) except: raise AttributeError('The passed function is not an attribute of Edge') raise AttributeError(func, ' is not an attribute of Edge') else: function(*args, **kwargs) Loading @@ -391,66 +397,12 @@ class CandidateGraph(nx.Graph): boolean mask for edges in the minimum spanning tree """ self.graph_masks = pd.DataFrame(False, index=self.edges(), columns=['mst']) graph_mask = pd.Series(False, index=self.edges()) self.graph_masks['mst'] = graph_mask mst = nx.minimum_spanning_tree(self) self.graph_masks['mst'][mst.edges()] = True def symmetry_checks(self): """ Perform a symmetry check on all edges in the graph """ for s, d, edge in self.edges_iter(data=True): edge.symmetry_check() def ratio_checks(self, clean_keys=[], **kwargs): """ Perform a ratio check on all edges in the graph """ for s, d, edge in self.edges_iter(data=True): edge.ratio_check(clean_keys=clean_keys) def compute_homographies(self, clean_keys=[], **kwargs): """ Compute homographies for all edges using identical parameters Parameters ---------- clean_keys : list Of keys in the mask dict """ for s, d, edge in self.edges_iter(data=True): edge.compute_homography(clean_keys=clean_keys, **kwargs) def compute_fundamental_matrices(self, clean_keys=[], **kwargs): """ Compute fundamental matrices for all edges using identical parameters Parameters ---------- clean_keys : list Of keys in the mask dict """ for s, d, edge in self.edges_iter(data=True): edge.compute_fundamental_matrix(clean_keys=clean_keys, **kwargs) def subpixel_register(self, clean_keys=[], threshold=0.8, upsampling=10, template_size=9, search_size=27, tiled=False, **kwargs): """ Compute subpixel offsets for all edges using identical parameters """ for s, d, edge in self.edges_iter(data=True): edge.subpixel_register(clean_keys=clean_keys, threshold=threshold, upsampling=upsampling, template_size=template_size, search_size=search_size, tiled=tiled, **kwargs) def suppress(self, clean_keys=[], func=spf.correlation, **kwargs): for s, d, e in self.edges_iter(data=True): e.suppress(clean_keys=clean_keys, func=func, **kwargs) def to_filelist(self): """ Generate a file list for the entire graph. Loading Loading @@ -503,7 +455,6 @@ class CandidateGraph(nx.Graph): : C the cleaned control network """ mask = np.zeros(len(cnet), dtype=bool) counter = 0 for i, group in cnet.groupby('pid'): Loading
functional_tests/test_three_image.py +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ class TestThreeImageMatching(unittest.TestCase): for source, destination, edge in cg.edges_iter(data=True): edge.symmetry_check() edge.ratio_check(clean_keys=['symmetry'], ratio=0.99) cg.compute_homographies(clean_keys=['symmetry', 'ratio']) cg.apply_func_to_edges("compute_homography", clean_keys=['symmetry', 'ratio']) # Step: And create a C object cnet = cg.to_cnet(clean_keys=['symmetry', 'ratio', 'ransac']) Loading
functional_tests/test_two_image.py +2 −2 Original line number Diff line number Diff line Loading @@ -73,14 +73,14 @@ class TestTwoImageMatching(unittest.TestCase): self.assertIn(edge.masks['ratio'].sum(), range(40, 100)) # Step: Compute the homographies and apply RANSAC cg.compute_homographies(clean_keys=['symmetry', 'ratio']) cg.apply_func_to_edges("compute_homography", clean_keys=['symmetry', 'ratio']) # Step: Compute the overlap ratio and coverage ratio for s, d, edge in cg.edges_iter(data=True): edge.coverage_ratio(clean_keys=['symmetry', 'ratio']) # Step: Compute subpixel offsets for candidate points cg.subpixel_register(clean_keys=['ransac']) cg.apply_func_to_edges("subpixel_register", clean_keys=['ransac']) # Step: And create a C object cnet = cg.to_cnet(clean_keys=['symmetry', 'ratio', 'ransac', 'subpixel']) Loading
notebooks/Tutorial with Visualization.ipynb +61 −35 File changed.Preview size limit exceeded, changes collapsed. Show changes