16 Nov 2010

Image Compression using DCT

Image Compression using DCT


clc;

clear all;

close all;


I = imread('cameraman.tif');

I = im2double(I);

T = dctmtx(8);

B = blkproc(I,[8 8],'P1*x*P2',T,T');

mask = [1 1 1 1 0 0 0 0

1 1 1 0 0 0 0 0

1 1 0 0 0 0 0 0

1 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0];

B2 = blkproc(B,[8 8],'P1.*x',mask);

I2 = blkproc(B2,[8 8],'P1*x*P2',T',T);

subplot(121);imshow(I);title('Original Image');

subplot(122);imshow(I2);title('Compressed Image');


No comments: