Loading .coveragerc +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ source = autocnet omit = fileio/ControlNetFileV0002_pb2.py utils/visualization.py vis/* exclude_lines = pragma: no cover def __repr__ Loading autocnet/examples/Apollo15/two_image_adjacency.json +2 −4 Original line number Diff line number Diff line {"autocnet/examples/Apollo15/AS15-M-0297_SML.png" : ["autocnet/examples/Apollo15/AS15-M-0298_SML.png"], "autocnet/examples/Apollo15/AS15-M-0298_SML.png" : ["autocnet/examples/Apollo15/AS15-M-0297_SML.png"]} {"AS15-M-0297_SML.png" : ["AS15-M-0298_SML.png"], "AS15-M-0298_SML.png" : ["AS15-M-0297_SML.png"]} autocnet/graph/network.py +7 −8 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from autocnet.matcher import feature_extractor as fe # extract features from ima from autocnet.matcher import outlier_detector as od from autocnet.matcher import subpixel as sp from autocnet.cg.cg import convex_hull_ratio, overlapping_polygon_area from autocnet.vis.graph_view import plot_node class Edge(object): """ Loading Loading @@ -325,6 +325,7 @@ class Node(object): mask = od.adaptive_non_max_suppression(self.keypoints,nfeatures,robust) self.masks = ('anms', mask) def convex_hull_ratio(self, clean_keys=[]): """ Compute the ratio $area_{convexhull} / area_{total}$ Loading @@ -347,6 +348,9 @@ class Node(object): ratio = convex_hull_ratio(keypoints, ideal_area) return ratio def plot(self, clean_keys=[], **kwargs): return plot_node(self, clean_keys=clean_keys, **kwargs) def update(self, *args): # Empty pass method to get NetworkX to accept a non-dict pass Loading Loading @@ -377,13 +381,8 @@ class CandidateGraph(nx.Graph): # the node_name is the relative path for the image for node_name, node in self.nodes_iter(data=True): if os.path.isabs(node_name): image_name = os.path.basename(node_name) image_path = node_name else: image_name = os.path.basename(os.path.abspath(node_name)) image_path = os.path.abspath(node_name) # Replace the default node dict with an object self.node[node_name] = Node(image_name, image_path) Loading autocnet/vis/__init__.py 0 → 100644 +0 −0 Empty file added. autocnet/utils/visualization.py→autocnet/vis/graph_view.py +38 −27 Original line number Diff line number Diff line Loading @@ -8,12 +8,9 @@ from autocnet.fileio.io_gdal import GeoDataset # set handle, get image as array from matplotlib import pyplot as plt # plotting def plotFeatures(imageName, keypoints, pointColorAndHatch='b.', featurePointSize=7): def plot_node(node, ax=None, clean_keys=[], **kwargs): """ Plot an image and its found features using the image file name and a keypoint list found using autocnet.feature_extractor. The user may also specify the color and style of the points to be plotted and the size of the points. Plot the array and keypoints for a given node. Parameters ---------- Loading @@ -21,35 +18,49 @@ def plotFeatures(imageName, keypoints, pointColorAndHatch='b.', featurePointSize The base name of the image file (without path). This will be the title of the plot. keypoints : list The keypoints of this image found by the feature extractor. ax : object A MatPlotLIb axes object pointColorAndHatch : str The color and hatch (symbol) to be used to mark the found features. Defaults to 'b.', blue and square dot. See matplotlib documentation for more choices. featurePointSize : int The size of the point marker. Defaults to 7. clean_keys : list of strings of masking array names to apply kwargs : dict of MatPlotLib plotting options """ imgArray = GeoDataset(get_path(imageName)).read_array() height, width = imgArray.shape[:2] if ax is None: ax = plt.gca() displayBox = np.zeros((height, width), np.uint8) displayBox[:height, :width] = imgArray band = 1 if 'band' in kwargs.keys(): band = kwargs['band'] kwargs.pop('band', None) plt.title(imageName) plt.margins(tight=True) plt.axis('off') plt.imshow(displayBox, cmap='Greys') array = node.get_array(band) for kp in keypoints: x,y = kp.pt plt.plot(x,y,pointColorAndHatch, markersize=featurePointSize) ax.set_title(node.image_name) ax.margins(tight=True) ax.axis('off') if 'cmap' in kwargs: cmap = kwargs['cmap'] else: cmap = 'Greys' ax.imshow(array, cmap=cmap) keypoints = node.keypoints if clean_keys: mask = np.prod([node._mask_arrays[i] for i in clean_keys], axis=0, dtype=np.bool) keypoints = node.keypoints[mask] marker = '.' if 'marker' in kwargs.keys(): marker = kwargs['marker'] kwargs.pop('marker', None) ax.scatter(keypoints['x'], keypoints['y'], marker=marker, **kwargs) return ax def plotAdjacencyGraphFeatures(graph, pointColorAndHatch='b.', featurePointSize=7): Loading Loading
.coveragerc +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ source = autocnet omit = fileio/ControlNetFileV0002_pb2.py utils/visualization.py vis/* exclude_lines = pragma: no cover def __repr__ Loading
autocnet/examples/Apollo15/two_image_adjacency.json +2 −4 Original line number Diff line number Diff line {"autocnet/examples/Apollo15/AS15-M-0297_SML.png" : ["autocnet/examples/Apollo15/AS15-M-0298_SML.png"], "autocnet/examples/Apollo15/AS15-M-0298_SML.png" : ["autocnet/examples/Apollo15/AS15-M-0297_SML.png"]} {"AS15-M-0297_SML.png" : ["AS15-M-0298_SML.png"], "AS15-M-0298_SML.png" : ["AS15-M-0297_SML.png"]}
autocnet/graph/network.py +7 −8 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from autocnet.matcher import feature_extractor as fe # extract features from ima from autocnet.matcher import outlier_detector as od from autocnet.matcher import subpixel as sp from autocnet.cg.cg import convex_hull_ratio, overlapping_polygon_area from autocnet.vis.graph_view import plot_node class Edge(object): """ Loading Loading @@ -325,6 +325,7 @@ class Node(object): mask = od.adaptive_non_max_suppression(self.keypoints,nfeatures,robust) self.masks = ('anms', mask) def convex_hull_ratio(self, clean_keys=[]): """ Compute the ratio $area_{convexhull} / area_{total}$ Loading @@ -347,6 +348,9 @@ class Node(object): ratio = convex_hull_ratio(keypoints, ideal_area) return ratio def plot(self, clean_keys=[], **kwargs): return plot_node(self, clean_keys=clean_keys, **kwargs) def update(self, *args): # Empty pass method to get NetworkX to accept a non-dict pass Loading Loading @@ -377,13 +381,8 @@ class CandidateGraph(nx.Graph): # the node_name is the relative path for the image for node_name, node in self.nodes_iter(data=True): if os.path.isabs(node_name): image_name = os.path.basename(node_name) image_path = node_name else: image_name = os.path.basename(os.path.abspath(node_name)) image_path = os.path.abspath(node_name) # Replace the default node dict with an object self.node[node_name] = Node(image_name, image_path) Loading
autocnet/utils/visualization.py→autocnet/vis/graph_view.py +38 −27 Original line number Diff line number Diff line Loading @@ -8,12 +8,9 @@ from autocnet.fileio.io_gdal import GeoDataset # set handle, get image as array from matplotlib import pyplot as plt # plotting def plotFeatures(imageName, keypoints, pointColorAndHatch='b.', featurePointSize=7): def plot_node(node, ax=None, clean_keys=[], **kwargs): """ Plot an image and its found features using the image file name and a keypoint list found using autocnet.feature_extractor. The user may also specify the color and style of the points to be plotted and the size of the points. Plot the array and keypoints for a given node. Parameters ---------- Loading @@ -21,35 +18,49 @@ def plotFeatures(imageName, keypoints, pointColorAndHatch='b.', featurePointSize The base name of the image file (without path). This will be the title of the plot. keypoints : list The keypoints of this image found by the feature extractor. ax : object A MatPlotLIb axes object pointColorAndHatch : str The color and hatch (symbol) to be used to mark the found features. Defaults to 'b.', blue and square dot. See matplotlib documentation for more choices. featurePointSize : int The size of the point marker. Defaults to 7. clean_keys : list of strings of masking array names to apply kwargs : dict of MatPlotLib plotting options """ imgArray = GeoDataset(get_path(imageName)).read_array() height, width = imgArray.shape[:2] if ax is None: ax = plt.gca() displayBox = np.zeros((height, width), np.uint8) displayBox[:height, :width] = imgArray band = 1 if 'band' in kwargs.keys(): band = kwargs['band'] kwargs.pop('band', None) plt.title(imageName) plt.margins(tight=True) plt.axis('off') plt.imshow(displayBox, cmap='Greys') array = node.get_array(band) for kp in keypoints: x,y = kp.pt plt.plot(x,y,pointColorAndHatch, markersize=featurePointSize) ax.set_title(node.image_name) ax.margins(tight=True) ax.axis('off') if 'cmap' in kwargs: cmap = kwargs['cmap'] else: cmap = 'Greys' ax.imshow(array, cmap=cmap) keypoints = node.keypoints if clean_keys: mask = np.prod([node._mask_arrays[i] for i in clean_keys], axis=0, dtype=np.bool) keypoints = node.keypoints[mask] marker = '.' if 'marker' in kwargs.keys(): marker = kwargs['marker'] kwargs.pop('marker', None) ax.scatter(keypoints['x'], keypoints['y'], marker=marker, **kwargs) return ax def plotAdjacencyGraphFeatures(graph, pointColorAndHatch='b.', featurePointSize=7): Loading