utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:joint-demosaicing-denoising-sem 作者: VLOGroup 项目源码 文件源码
def DCT(width, height, depth):
    N = width
    M = depth
    filtMtx = np.zeros((N*N*M, N*N*M))
    xn = np.arange(0,N)
    Xn, Yn = np.meshgrid(xn,xn, sparse=False)
    xm = np.arange(0,M)
    Xm, Ym = np.meshgrid(xm,xm, sparse=False)

    dctBasisN = np.cos((np.pi / N) * (Yn + 0.5)*Xn)
    dctBasisN = np.mat(dctBasisN)
    dctBasisM = np.cos((np.pi / M) * (Ym + 0.5)*Xm)
    dctBasisM = np.mat(dctBasisM)

    for i in range(0,N):
        for j in range(0,N):
            filt2d = dctBasisN[:,j].dot(dctBasisN[:,i].T)
            filt2d = filt2d.reshape(N**2,1)
            for k in range(0,M):
                filt = filt2d.dot(dctBasisM[:,k].T)
                filt = filt/np.linalg.norm(filt)  # L2 normalization
                filtMtx[:,j*N+k*N*N + i] = filt.reshape(N*N*M)
    return filtMtx.astype("float32")[:,1:]

#load parameters theta from file
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号