q=0.2;

C=imread('Lenna.png');

A=double(C(:,:,1));
[m,n]=size(A);

figure(1);
image(A);
colormap(gray(256));
colorbar;

figure(2);
B=dht2(A,'single');
imagesc(B);
colormap(gray(256));
colorbar;

figure(3);
B=dht2(A,'full');
imagesc(B);
colormap(gray(256));
colorbar;

% retain only the largest coefficients
b=reshape(B,n*m,1);
[c,I]=sort(abs(b),'descend');
b(I(round(q*m*n):end))=0;
B=reshape(b,m,n);

figure(4);
AA=idht2(B,'full');
image(AA);
colormap(gray(256));
colorbar;


