Ejemplo n.º 1
0
def current_reference(Y1,
                      Y2,
                      cout,
                      pixel,
                      prob_residual,
                      prob_motion,
                      codebook_residual=None,
                      codebook_motion=None):

    _block = Block()
    global compressed
    # convert uint8 to int32
    Y1 = np.int32(Y1)
    Y2 = np.int32(Y2)

    Mvector, Ry = _block.Intercoding(Y1, Y2, pixel, macro)
    for vec in Mvector:
        prob_motion[
            vec] = 0 if vec not in prob_motion else prob_motion[vec] + 1
    if codebook_motion:
        compressed += "".join(entropyCoding(codebook_motion, Mvector))
    # print Ry
    DCT_Ry = _block.DCT(Ry, pixel)
    # print DCT_Ry.dtype

    Rys = blockshaped(DCT_Ry, pixel, pixel)

    IRys = Rys.copy()
    for i, Ry in enumerate(Rys):
        Quantised_Ry = quantise(Ry)

        reordered_Ry = reorder(prob_residual, Quantised_Ry)

        if codebook_residual:
            compressed += "".join(
                entropyCoding(codebook_residual, reordered_Ry))

        inverse_reordered_Ry = inverseReorder(reordered_Ry)

        Dequantised_Ry = rescale(Quantised_Ry)

        IRys[i] = Dequantised_Ry
    IRys = mergeshaped(IRys, height, width)
    # print DCT_Ry
    IDCT_Ry = _block.IDCT(IRys, pixel)
    # print IDCT_Ry.dtype
    # print IDCT_Ry
    D_img = _block.Reconstruct(Y2, IDCT_Ry, Mvector, pixel)

    return D_img
Ejemplo n.º 2
0
def current_reference(Y1, Y2, cout, pixel):

    _block = Block()

    # convert uint8 to int32
    Y1 = np.int32(Y1)
    Y2 = np.int32(Y2)

    Mvector, Ry = _block.Intercoding(Y1, Y2, pixel, macro)
    DCT_Ry = _block.DCT(Ry, pixel)
    IDCT_Ry = _block.IDCT(DCT_Ry, pixel)

    D_img = _block.Reconstruct(Y2, IDCT_Ry, Mvector, pixel)

    return D_img