def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max() > 10:
        im = np.float32(im) / 255
    locsDoG, gaussian_pyramid = DoGdetector(im,
                                            sigma0=1,
                                            k=np.sqrt(2),
                                            levels=[-1, 0, 1, 2, 3, 4],
                                            th_contrast=0.03,
                                            th_r=12)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, compareX,
                              compareY)
    return locs, desc
Exemple #2
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors.
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...
    locsDoG, gaussian_pyramid = DoGdetector(im)
    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max() > 10:
        im = np.float32(im) / 255
    # for i in range(locsDoG.shape[0]):
    #     cv2.circle(im, (locsDoG[i,0], locsDoG[i,1]), 1, color=(0,255,0), lineType=cv2.LINE_AA)
    # cv2.namedWindow("image", cv2.WINDOW_NORMAL)
    # cv2.imshow('image', im)
    locs, desc = computeBrief(im, locsDoG, gaussian_pyramid, compareX,
                              compareY)

    return locs, desc
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...

    locsDoG, gaussian_pyramid = DoGdetector(im)
    test_pattern_file = '/home/geekerlink/Desktop/Computer Vision/Homeworks/hw3/results/testPattern.npy'
    compareX, compareY = np.load(test_pattern_file)

    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max() > 10:
        im = np.float32(im) / 255
    k = np.sqrt(2)
    levels = [-1, 0, 1, 2, 3, 4]
    #print("locsdog")
    #print(locsDoG.shape)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, k, levels,
                              compareX, compareY)

    return locs, desc
Exemple #4
0
def briefLite(im):
    '''
    INPUTS
        im - gray image with values between 0 and 1

    OUTPUTS
        locs - an m x 3 vector, where the first two columns are the image coordinates
            of keypoints and the third column is the pyramid level of the keypoints
        desc - an m x n bits matrix of stacked BRIEF descriptors.
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''

    ###################
    # TO DO ...
# load test pattern for Brief
    test_pattern_file = '../results/testPattern.npy'
    if os.path.isfile(test_pattern_file):
        # load from file if exists
        compareX, compareY = np.load(test_pattern_file)
    else:
        # produce and save patterns if not exist
        compareX, compareY = makeTestPattern()
        if not os.path.isdir('../results'):
            os.mkdir('../results')
        np.save(test_pattern_file, [compareX, compareY])
    k = 1
    levels = [-1,0,1,2,3,4]
    locs, gaussian_pyramid = DoGdetector(im, k, np.sqrt(2), levels, 0.03, 12)
    locs, desc = computeBrief(im, gaussian_pyramid, locs, k, levels, compareX, compareY)



    return locs, desc
def briefLite(im):
    '''
    INPUTS
        im - gray image with values between 0 and 1

    OUTPUTS
        locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
        desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''

    ###################
    # TO DO ...
    levels = [-1, 0, 1, 2, 3, 4]
    k = np.sqrt(2)
    locsDoG, gaussian_pyramid = DoGdetector(im)
    test_pattern_file = '../results/testPattern.npy'
    compareX, compareY = np.load(test_pattern_file)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, k, levels,
                              compareX, compareY)
    #print(desc.shape)
    #print(locs.shape)
    #print(compareX.shape)
    #print(compareY.shape)
    #print(locsDoG.shape)
    #print(gaussian_pyramid.shape)

    return locs, desc
Exemple #6
0
def briefLite(im):
    '''
    INPUTS
        im - gray image with values between 0 and 1

    OUTPUTS
        locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
        desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    
    ###################
    # TO DO ...
    if len(im.shape)==3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max()>10:
        im = np.float32(im)/255
    k=np.sqrt(2)
    levels=[-1,0,1,2,3,4]
    test_pattern_file = '../results/testPattern.npy'
    if os.path.isfile(test_pattern_file):
        # load from file if exists
        compareX, compareY = np.load(test_pattern_file)
    locsDoG, gaussian_pyramid = DoGdetector(im,th_contrast = 0.03,th_r = 12)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, k, levels, compareX, compareY)
    return locs, desc
Exemple #7
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...

    # GRAYSCALE AND NORMALIZATION HANDELED IN CODE OF GAUSSIAN PYRAMID
    locsDoG, gaussian_pyramid = DoGdetector(im)
    print('locsDoG shape:  ', locsDoG.shape)

    compareX, compareY = np.load(test_pattern_file)

    locs, desc = computeBrief(im,
                              gaussian_pyramid,
                              locsDoG,
                              k=9,
                              levels=gaussian_pyramid.shape[2],
                              compareX=compareX,
                              compareY=compareY)
    return locs, desc
Exemple #8
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...

    k = np.sqrt(2)
    levels = [0, 1, 2, 3, 4]
    locsDoG, gaussian_pyramid = DoGdetector(im)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, k, levels,
                              compareX, compareY)

    # print ("shape of locs is")
    # print (locs.shape)
    # print ("shape of desc is")
    # print (desc.shape)
    # print (locs)
    return locs, desc
Exemple #9
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...
    levels = None
    k = None

    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max() > 10:
        im = np.float32(im) / 255

    locsDoG, gaussian_pyramid = DoGdetector(im)
    compareX, compareY = np.load('../results/testPattern.npy')
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, k, levels,
                              compareX, compareY)
    return locs, desc
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    locsDoG, gauss_pyramid = DoGdetector(im)
    locs, desc = computeBrief(im, gauss_pyramid, locsDoG, np.sqrt(2), [-1,0,1,2,3,4], compareX, compareY)
    return locs, desc
Exemple #11
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # Computer DoG
    locsDoG, gaussian_pyramid = DoGdetector(im)

    # Perform BRIEF to get the descriptors of feature points
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, compareX, compareY)
    return locs, desc
Exemple #12
0
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    locs, gaussian_pyramid = DoGdetector(im)
    # we use sample pattern saved as global
    locs, desc = computeBrief(im, gaussian_pyramid, locs, None, None, compareX,
                              compareY)
    return locs, desc
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''

    test_pattern_file = '../results/testPattern.npy'
    compareX, compareY = np.load(test_pattern_file)
    locsDoG, gaussian_pyramid = DoGdetector(im)
    locs, desc = computeBrief(im, locsDoG, compareX, compareY)

    return locs, desc
def briefLite(im):
    '''
    INPUTS
    im - gray image with values between 0 and 1

    OUTPUTS
    locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
    desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    ###################
    # TO DO ...
    locsDoG, gaussian_pyramid = DoGdetector(im)
    compare = np.load('../results/testPattern.npy')
    print(np.shape(compare))
    compareX = compare[0]
    compareY = compare[1]
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, np.sqrt(2),
                              [-1, 0, 1, 2, 3, 4], compareX, compareY)

    return locs, desc
def briefLite(im):
    '''
    INPUTS
        im - gray image with values between 0 and 1

    OUTPUTS
        locs - an m x 3 vector, where the first two columns are the image coordinates 
            of keypoints and the third column is the pyramid level of the keypoints
        desc - an m x n bits matrix of stacked BRIEF descriptors. 
            m is the number of valid descriptors in the image and will vary
            n is the number of bits for the BRIEF descriptor
    '''
    
    ###################
    # TO DO ...

    # For BRIEF computation, convert to gray scale of one channel
    if len(im.shape) == 3:
        im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
    if im.max() > 10:
        im = np.float32(im) / 255

    test_pattern_file = '../results/testPattern.npy'
    if os.path.isfile(test_pattern_file):
        # load from file if exists
        compareX, compareY = np.load(test_pattern_file)
    else:
        # produce and save patterns if not exist
        compareX, compareY = makeTestPattern(patch_width=9, nbits=256)
        if not os.path.isdir('../results'):
            os.mkdir('../results')
        np.save(test_pattern_file, [compareX, compareY])

    locsDoG, gaussian_pyramid = DoGdetector(im)
    locs, desc = computeBrief(im, gaussian_pyramid, locsDoG, 9, [-1,0,1,2,3,4], compareX, compareY)

    return locs, desc