Example #1
0
def lowrescv(limg, rimg, dmax=96):
    shp = tf.shape(limg)[1:]
    ht, wd = shp[0], shp[1]
    ys, xs = tf.mod(ht, 2), tf.mod(wd, 2)

    limg = tf.pad(
        limg, tf.stack([[0, 0],
                        tf.stack([ys, 0]),
                        tf.stack([xs, 0]), [0, 0]]), 'SYMMETRIC')
    limg = tf.nn.avg_pool(limg, [1, 2, 2, 1], [1, 2, 2, 1], 'VALID')

    rimg = tf.pad(
        rimg, tf.stack([[0, 0],
                        tf.stack([ys, 0]),
                        tf.stack([xs, 0]), [0, 0]]), 'SYMMETRIC')
    rimg = tf.nn.avg_pool(rimg, [1, 2, 2, 1], [1, 2, 2, 1], 'VALID')

    lrl = limg
    limg, rimg = tf.image.rgb_to_yuv(limg), tf.image.rgb_to_yuv(rimg)
    limg, rimg = slib.census(limg), slib.census(rimg)

    cv = slib.hamming(limg, rimg, 0, 0, (shp[0] + 1) // 2, (shp[1] + 1) // 2,
                      dmax)
    cv = (cv - [11.08282948, 0.02175535, 0.02679042
                ]) * [0.1949711, 35.91432953, 26.79782867]
    shp = tf.shape(cv)
    cv = tf.reshape(cv, tf.stack([shp[0], shp[1], shp[2], -1]))
    return cv, lrl
Example #2
0
def lowrescv(limg, rimg, imsz, dmax=96):
    limg = tf.nn.avg_pool(limg, [1, 2, 2, 1], [1, 2, 2, 1], 'VALID')
    rimg = tf.nn.avg_pool(rimg, [1, 2, 2, 1], [1, 2, 2, 1], 'VALID')

    lim0 = limg
    limg, rimg = tf.image.rgb_to_yuv(limg), tf.image.rgb_to_yuv(rimg)
    limg, rimg = slib.census(limg), slib.census(rimg)

    cv = slib.hamming(limg, rimg, 0, 0, imsz[0] // 2, imsz[1] // 2, dmax)
    cv = (cv - [11.08282948, 0.02175535, 0.02679042
                ]) * [0.1949711, 35.91432953, 26.79782867]
    shp = tf.shape(cv)
    cv = tf.reshape(cv, tf.stack([shp[0], shp[1], shp[2], -1]))
    return cv, lim0