Commit 223df41c authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Merge pull request #209 from acpaquette/subpixel

Subpixel Dataframe
parents 1788194d b61fe765
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class Edge(dict, MutableMapping):
        self['fundamental_matrix'] = None
        self.matches = pd.DataFrame()
        self.masks = pd.DataFrame()
        self.subpixel_matches = pd.DataFrame()
        self['weights'] = {}
        self['source_mbr'] = None
        self['destin_mbr'] = None
@@ -297,10 +298,9 @@ class Edge(dict, MutableMapping):
                      The maximum (positive) value that a pixel can shift in the y direction
                      without being considered an outlier
        """
        matches = self.matches
        for column, default in {'x_offset': 0, 'y_offset': 0, 'correlation': 0, 'reference': -1}.items():
            if column not in self.matches.columns:
                self.matches[column] = default
            if column not in self.subpixel_matches.columns:
                self.subpixel_matches[column] = default

        # Build up a composite mask from all of the user specified masks
        matches, mask = self.clean(clean_keys)
@@ -328,18 +328,17 @@ class Edge(dict, MutableMapping):
            d_search = sp.clip_roi(d_img, d_keypoint, search_size)
            try:
                x_offset, y_offset, strength = sp.subpixel_offset(s_template, d_search, **kwargs)
                self.matches.loc[idx, ('x_offset', 'y_offset',
                                       'correlation', 'reference')] = [x_offset, y_offset, strength, source_image]
                self.subpixel_matches.loc[idx, ('x_offset', 'y_offset', 'correlation', 'reference')]= [x_offset, y_offset, strength, source_image]
            except:
                warnings.warn('Template-Search size mismatch, failing for this correspondence point.')

        # Compute the mask for correlations less than the threshold
        threshold_mask = self.matches['correlation'] >= threshold
        threshold_mask = self.subpixel_matches['correlation'] >= threshold

        # Compute the mask for the point shifts that are too large
        query_string = 'x_offset <= -{0} or x_offset >= {0} or y_offset <= -{1} or y_offset >= {1}'.format(max_x_shift,max_y_shift)
        sp_shift_outliers = self.matches.query(query_string)
        shift_mask = pd.Series(True, index=self.matches.index)
        sp_shift_outliers = self.subpixel_matches.query(query_string)
        shift_mask = pd.Series(True, index=self.subpixel_matches.index)
        shift_mask.loc[sp_shift_outliers.index] = False

        # Generate the composite mask and write the masks to the mask data structure
+33 −11

File changed.

Contains only whitespace changes.