Approximation test
Here is a script that tests all the approximation routines on the Lena image, which is assumed to have been saved as a Matlab .mat file.
load Lena
figure(1);image(Lena); axis image; title 'original';
[m,n,k] = size(Lena);
[Y,Cb,Cr]=convertYCbCr(Lena);
% grayscale wavelet compression
WaveletOrder = 6;
scale = 9;
ratio = 20;
g = grayWaveletCompress(Y,WaveletOrder,scale,ratio);
figure(2);colormap(gray(256));image(g),axis image;
title 'grayscale wavelet approximation'
% color compression
[wb,wr] = colorCompress(Cb,Cr,20);
compressedImage=convertYC2RGB(g,wb,wr);
figure(3);image(compressedImage),axis image;
title 'color wavelet approximation'
As a whole, this scheme essentially divides the image size by 20. The output image is below; it has been converted to JPEG for internet usage, so it is best that you display it in Matlab to see the true result.
and here is the result for the Mandrill image, also with a ratio of 20.
Some details are lost in the lower part of the image. We can try to improve it
by lowering the grayscale ratio to 5
Improving the grayscale image by reducing the ratio restores much hair
on the mandrill's face. The chrominance is unchanged.