Ejemplo n.º 1
0
def idct2(X, blksize):
    """Calculate the inverse DCT transform of a 2D array, X"""
    dctm = dct_mat(blksize)

    #try:
    blks = [sp.vsplit(x, X.shape[1]/blksize) for x in sp.hsplit(X, X.shape[0]/blksize)]
    #except:
    #    print "Some error occurred"

    blks = [sp.dot(sp.dot(dctm.T, b), dctm) for b in blks]
    return sp.concatenate([blk for blk in blks]).reshape(X.shape)
Ejemplo n.º 2
0
def dct2(X, blksize):
    """Calculate DCT transform of a 2D array, X

    In order for this work, we have to split X into blksize chunks"""
    dctm = dct_mat(blksize)

    #try:
    blks = [sp.vsplit(x, X.shape[1]/blksize) for x in sp.hsplit(X, X.shape[0]/blksize)]
    #except:
    #    print "Some error occurred"

    blks = [sp.dot(sp.dot(dctm, b), dctm.T) for b in blks]
    return sp.concatenate([blk for blk in blks]).reshape(X.shape)