Unverified Commit dd77e5eb authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Adds smart subpixel matcher (#605)

* Adds smart subpixel matcher

* Check in subpixel and turns off failing provenence on points/measures

* Updates for comments on review

* Updates for missed comments

* Updates for comments

* Updates for comments

* Fixes bug where geodata is always none

* Updates for comments
parent 3f30fd3a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -229,3 +229,6 @@ def main(): # pragma: no cover
    # Get the message
    queue = StrictRedis(host=args['host'], port=args['port'], db=0)
    manage_messages(args, queue)
    
if __name__ == '__main__':
    main()
+22 −2
Original line number Diff line number Diff line
@@ -310,6 +310,26 @@ class CandidateGraph(nx.Graph):
        """
        return self.nodes[node_index]['data']['image_name']

    def get_index(self, image_name):
        """
        Get the node index using the full or partial image name.

        Parameters
        ----------
        image_name : str
                     That is matched using a simple 'in' check to 
                     node['image_name']
        
        Returns  
        -------
        i : int
            The node index
        """

        for i, node in self.nodes(data='data'):
            if image_name in node['image_name']:
                return i

    def get_matches(self, clean_keys=[]):
        matches = []
        for s, d, e in self.edges_iter(data=True):
@@ -1642,6 +1662,8 @@ class NetworkCandidateGraph(CandidateGraph):
        return len(res)

    def _push_iterable_message(self, iterable, function, walltime, args, kwargs):
        if not iterable:  # the list is empty...
            raise ValueError('iterable is not an iterable object, e.g., a list or set')
        for job_counter, item in enumerate(iterable):
            msg = {'along':item,
                    'func':function,
@@ -1913,8 +1935,6 @@ class NetworkCandidateGraph(CandidateGraph):
                                        radsigma,
                                        self.config['spatial']['semimajor_rad'])

        print("df shape: ", df.shape)

        if flistpath is None:
            flistpath = os.path.splitext(path)[0] + '.lis'
        target = self.config['spatial'].get('target', None)
+3 −10
Original line number Diff line number Diff line
@@ -161,16 +161,9 @@ class Node(dict, MutableMapping):

    @property
    def geodata(self):
        if not getattr(self, '_geodata', None) and self['image_path'] is not None:
            try:
        if not hasattr(self, '_geodata'):
            self._geodata = GeoDataset(self['image_path'])
        return self._geodata
            except:
                return self['node_id']
        if hasattr(self, '_geodata'):
            return self._geodata
        else:
            return None

    @property
    def footprint(self):
+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,15 @@ def mutual_information(t1, t2, **kwargs):
    --------
    numpy.histogram2d : for the kwargs that can be passed to the comparison
    """

    if np.isnan(t1).any() or np.isnan(t2).any():
        print('Unable to process due to NaN values in the input data')
        return
    
    if t1.shape != t2.shape:
        print('Unable compute MI. Image sizes are not identical.')
        return

    hgram, x_edges, y_edges = np.histogram2d(t1.ravel(),t2.ravel(), **kwargs)

    # Convert bins counts to probability values
+1 −5
Original line number Diff line number Diff line
@@ -75,8 +75,6 @@ def pattern_match_autoreg(template, image, subpixel_size=3, metric=cv2.TM_CCOEFF
    y += (template.shape[0] / 2)
    x += (template.shape[1] / 2)
    
    print('Results after shifting from the UL corner to the center of the template: ', y, x)
    
    x -= ideal_x
    y -= ideal_y
    
@@ -112,8 +110,6 @@ def pattern_match(template, image, upsampling=16, metric=cv2.TM_CCOEFF_NORMED, e
    strength : float
               The strength of the correlation in the range [-1, 1].
    """
    print('template avg: ', template.mean())
    print('image avg: ', image.mean())
    if upsampling < 1:
        raise ValueError

Loading