function CI = dctcompress(I,t)

[N,J] = size(I);

% Discrete Cosine Transform
dc = blkproc(I,[8 8],'dct2');
  
% Threshold cosine coefficients
temp = dc(1:8:N,1:8:N);
dc = wthresh(dc,'h',t);
dc(1:8:N,1:8:N) = temp;

% Count number of non-zero coefficients
nz = nnz(dc);

% Inverse Discrete Cosine Tranform
CI = real(blkproc(dc,[8 8],'idct2'));

% Print out the compression ratio
disp(['compression ration = ' num2str(N*J/nz)])
