Exemple #1
0
def subpixel_offset(template, search, **kwargs):
    """
    Uses a pattern-matcher on subsets of two images determined from the passed-in keypoints and optional sizes to
    compute an x and y offset from the search keypoint to the template keypoint and an associated strength.

    Parameters
    ----------
    template : ndarray
               The template used to search

    search : ndarray
             The search image

    Returns
    -------
    x_offset : float
               Shift in the x-dimension

    y_offset : float
               Shift in the y-dimension

    strength : float
               Strength of the correspondence in the range [-1, 1]
    """

    x_offset, y_offset, strength = matcher.pattern_match(template, search, **kwargs)
    return x_offset, y_offset, strength
Exemple #2
0
def subpixel_offset(template, search, upsampling=16):
    """
    Uses a pattern-matcher on subsets of two images determined from the passed-in keypoints and optional sizes to
    compute an x and y offset from the search keypoint to the template keypoint and an associated strength.

    Parameters
    ----------
    template : numpy array
                   The entire image that the template chip to match to will be taken out of.
    search : numpy array
                 The entire image that the search chip to match to the template chip will be taken out of.
    upsampling: int
                The amount to upsample the image. 
    Returns
    -------
    x_offset : float
               Shift in the x-dimension
    y_offset : float
               Shift in the y-dimension
    strength : float
               Strength of the correspondence in the range [-1, 1]
    """

    x_offset, y_offset, strength = matcher.pattern_match(template, search, upsampling=upsampling)
    return x_offset, y_offset, strength
Exemple #3
0
def subpixel_offset(template, search, upsampling=10):
    """
    Uses a pattern-matcher on subsets of two images determined from the passed-in keypoints and optional sizes to
    compute an x and y offset from the search keypoint to the template keypoint and an associated strength.

    Parameters
    ----------
    template_kp : KeyPoint
                  The KeyPoint to match the search_kp to.
    search_kp : KeyPoint
                The KeyPoint to match to the template_kp
    template_img : numpy array
                   The entire image that the template chip to match to will be taken out of.
    search_img : numpy array
                 The entire image that the search chip to match to the template chip will be taken out of.
    template_size : int
                    The length of one side of the square subset of the template image that will actually be used for
                    the subpixel registration. Default is 9.
                    Must be odd.
    search_size : int
                  The length of one side of the square subset of the search image that will be used for subpixel
                  registration. Default is 13. Must be odd.
    Returns
    -------
    : tuple
      The returned tuple is of form: (x_offset, y_offset, strength). The offsets are from the search to the template
      keypoint.
    """

    try:
        results = matcher.pattern_match(template, search, upsampling=upsampling)
        return results
    except ValueError:
        # the match fails if the template or search point is near an edge of the image
        # TODO: come up with a better solution?
        print('Can not subpixel match point.')
        return