Commit 03715ec5 authored by Jay's avatar Jay Committed by jay
Browse files

Update to subpixel to optionally load the entire image into memory.

parent e594ba08
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ class Edge(dict, MutableMapping):

    def subpixel_register(self, clean_keys=[], threshold=0.8, upsampling=16,
                          template_size=19, search_size=53, max_x_shift=1.0,
                          max_y_shift=1.0):
                          max_y_shift=1.0, tiled=False):
        """
        For the entire graph, compute the subpixel offsets using pattern-matching and add the result
        as an attribute to each edge of the graph.
@@ -264,6 +264,13 @@ class Edge(dict, MutableMapping):
        if clean_keys:
            matches, mask = self._clean(clean_keys)

        if tiled is True:
            s_img = self.source.handle
            d_img = self.destination.handle
        else:
            s_img = self.source.handle.read_array()
            d_img = self.destination.handle.read_array()

        # for each edge, calculate this for each keypoint pair
        for i, (idx, row) in enumerate(matches.iterrows()):
            s_idx = int(row['source_idx'])
@@ -273,8 +280,8 @@ class Edge(dict, MutableMapping):
            d_keypoint = self.destination.keypoints.iloc[d_idx][['x', 'y']].values

            # Get the template and search window
            s_template = sp.clip_roi(self.source.handle, s_keypoint, template_size)
            d_search = sp.clip_roi(self.destination.handle, d_keypoint, search_size)
            s_template = sp.clip_roi(s_img, s_keypoint, template_size)
            d_search = sp.clip_roi(d_img, d_keypoint, search_size)

            try:
                x_off, y_off, strength = sp.subpixel_offset(s_template, d_search, upsampling=upsampling)