コード例 #1
0
def runTexture(img_list):
    """ This function administrates the extraction of a video texture from the
      given frames.
    """
    video_volume = assignment11.videoVolume(img_list)
    ssd_diff = assignment11.sumSquaredDifferences(video_volume)
    transition_diff = assignment11.transitionDifference(ssd_diff)
    alpha = 1.5*10**6
    idxs = assignment11.findBiggestLoop(transition_diff, alpha)

    diff3 = np.zeros(transition_diff.shape, float)

    for i in range(transition_diff.shape[0]): 
        for j in range(transition_diff.shape[1]): 
            diff3[i,j] = alpha*(i-j) - transition_diff[i,j] 

    return vizDifference(ssd_diff), \
           vizDifference(transition_diff), \
           vizDifference(diff3), \
           assignment11.synthesizeLoop(video_volume, idxs[0]+2, idxs[1]+2)
コード例 #2
0
ファイル: main.py プロジェクト: sanzo1/cs6475-1
def runTexture(img_list, alpha):
    """ This function administrates the extraction of a video texture from the
    given frames, and generates the three viewable difference matrices.
    """
    video_volume = a11.videoVolume(img_list)
    ssd_diff = a11.computeSimilarityMetric(video_volume)
    transition_diff = a11.transitionDifference(ssd_diff)

    print "Alpha is {}".format(alpha)
    idxs = a11.findBiggestLoop(transition_diff, alpha)

    diff3 = np.zeros(transition_diff.shape, float)

    for i in range(transition_diff.shape[0]):
        for j in range(transition_diff.shape[1]):
            diff3[i, j] = alpha * (i - j) - transition_diff[i, j]

    return (vizDifference(ssd_diff),
            vizDifference(transition_diff),
            vizDifference(diff3),
            a11.synthesizeLoop(video_volume, idxs[0] + 2, idxs[1] + 2))
コード例 #3
0
def test_findBiggestLoop():
    diff1 = np.ones((5,5), dtype = float)
    alpha1 = 1
    out1 = (0,4)

    diff2 = np.array([[ 0.,  1.,  1.,  5.],
                      [ 1.,  0.,  3.,  4.],
                      [ 1.,  3.,  0.,  5.],
                      [ 5.,  4.,  5.,  0.]])
    alpha2 = 1 
    out2 = (0,2)

    diff3 = np.array([[ 0.,  1.,  4.],
                      [ 1.,  0.,  1.],
                      [ 4.,  1.,  0.]])   
    alpha3 = 2
    out3 = (0,1)

    for diff, alpha, true_out in zip((diff1, diff2, diff3),
                                     (alpha1, alpha2, alpha3),
                                     (out1, out2, out3)):
        print "Input:\n{}\n".format(diff)
        print "Alpha = {}".format(alpha)

        usr_out = assignment11.findBiggestLoop(diff, alpha)

        if type(usr_out) != type(true_out):
            print ("Error: findBiggestLoop has type {}. " +
                   "Expected type is {}.").format(type(usr_out), type(true_out))
            return False            

        if usr_out != true_out:
            print ("Error: findBiggestLoop is {}. " +
                   "Expected output is {}.").format(usr_out, true_out)
            return False

        print "Current input passed."
    print "findBiggestLoop passed."
    return True