M = int(N / CR) k1 = int(N / 8) dictype = 'DCT' # dictype = 'DFT' # dictype = None mestype = 'Gaussian' seed = 2019 if mestype is 'Gaussian': Phi = pys.gaussian((M, N), seed=seed, verbose=True) print("===observation...") if dictype is 'DCT': Psi = pys.dctdict(N) Psi = pys.dctmat(N) if dictype is 'DFT': # Psi = pys.dctdict(N) Psi = pys.dftmat(N) plt.figure() plt.subplot(221) plt.imshow(X) plt.title('Orignal image signal') if dictype is not None: plt.subplot(222) plt.imshow(np.abs(Psi)) plt.title('Dictionary matrix (' + dictype + ')') plt.subplot(223) plt.imshow(np.abs(np.reshape(np.matmul(Psi, X), (N, N))))
CR = 4 N = H M = int(N / CR) k1 = int(N / 8) dictype = 'DCT' mestype = 'Gaussian' seed = 2019 if mestype is 'Gaussian': Phi = pys.gaussian((M, N), seed=seed, verbose=True) print("===observation...") if dictype is 'DCT': D = pys.dctdict(N) A = np.matmul(Phi, D) plt.figure() plt.subplot(221) plt.imshow(X) plt.title('Orignal image signal') plt.subplot(222) plt.imshow(D) plt.title('Dictionary matrix (' + dictype + ')') plt.subplot(223) plt.imshow(np.reshape(np.matmul(D, X), (N, N))) plt.title('Sparse Coefficient (' + dictype + ')') plt.colorbar() plt.subplot(224)
# -*- coding: utf-8 -*- # @Date : 2017-07-06 10:38:13 # @Author : Yan Liu & Zhi Liu ([email protected]) # @Link : http://iridescent.ink # @Version : $1.0$ # import numpy as np import matplotlib.pyplot as plt import pysparse as pys import scipy.io as sio print("----------DCT-1D------------") N1 = 64 rcsize1 = (int(np.sqrt(N1)), int(np.sqrt(N1))) OD = pys.dctdict(N1) A1 = pys.showdict(OD, rcsize=rcsize1, stride=(0, 0), plot=False) N2 = 256 rcsize2 = (int(np.sqrt(N2)), int(np.sqrt(N2))) OD = pys.dctdict(N2) A2 = pys.showdict(OD, rcsize=rcsize2, stride=(0, 0), plot=False) N3 = 1024 rcsize3 = (int(np.sqrt(N3)), int(np.sqrt(N3))) OD = pys.dctdict(N3) A3 = pys.showdict(OD, rcsize=rcsize3, stride=(0, 0), plot=False) N4 = 4096 rcsize4 = (int(np.sqrt(N4)), int(np.sqrt(N4))) OD = pys.dctdict(N4)