0% found this document useful (0 votes)
21 views2 pages

'E:/img10.jpg': For For

The document implements image compression using the discrete cosine transform (DCT) in MATLAB. It reads an image, applies 1D DCTs along rows and columns, and reconstructs lower-resolution images by keeping only the first half, quarter, and eighth of DCT coefficients. It displays the original and compressed images for visual comparison of compression factors of 2, 4, and 8.

Uploaded by

medmode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

'E:/img10.jpg': For For

The document implements image compression using the discrete cosine transform (DCT) in MATLAB. It reads an image, applies 1D DCTs along rows and columns, and reconstructs lower-resolution images by keeping only the first half, quarter, and eighth of DCT coefficients. It displays the original and compressed images for visual comparison of compression factors of 2, 4, and 8.

Uploaded by

medmode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

>>o = imread ('e:\img10.

jpg');

w = size (o, 2);

samplesHalf = floor(w / 2);

samplesQuarter = floor(w / 4);

samplesEighth = floor(w / 8);

ci2 = [];

ci4 = [];

ci8 = []; for k=1:3 % all color layers: RGB for i=1:size(o, 1) % all rows

rowDCT = dct(double(o(i,:,k)));

ci2(i,:,k) = idct(rowDCT(1:samplesHalf), w);

ci4(i,:,k) = idct(rowDCT(1:samplesQuarter), w);

ci8(i,:,k) = idct(rowDCT(1:samplesEighth), w);

end

end h = size(o, 1);

samplesHalf = floor(h / 2);

samplesQuarter = floor(h / 4);

samplesEighth = floor(h / 8);

ci2f = [];

ci4f = [];

ci8f = []; for k=1:3 % all color layers: RGB

for i=1:size(o, 2) % all columns

PROJECT

IMAGE COMPRESSION USING DISCRETE COSINE TRANFORM IMPLEMENTING


MATLAB
columnDCT2=dct(double(ci2(:,i,k)));
columnDCT4=dct(double(ci4(:,i,k)));

columnDCT8=dct(double(ci8(:,i,k)));

ci2f(:,i,k) = idct(columnDCT2(1:samplesHalf), h);

ci4f(:,i,k) = idct(columnDCT4(1:samplesQuarter), h);

ci8f(:,i,k) = idct(columnDCT8(1:samplesEighth), h);

end

end subplot(2,2,1), image(uint8(o)), title('Original Image'); subplot(2,2,2), image(uint8(ci2)),


title('Compression Factor 2'); subplot(2,2,3), image(uint8(ci4)), title('Compression Factor 4');
subplot(2,2,4), image(uint8(ci8)), title('Compression Factor 8'); figure subplot(2,2,1),
image(uint8(o)), title('Original Image'); subplot(2,2,2), image(uint8(ci2f)), title('Compression
Factor 2 * 2'); subplot(2,2,3), image(uint8(ci4f)), title('Compression Factor 4 * 4');
subplot(2,2,4), image(uint8(ci8f)), title('Compression Factor 8 * 8');

You might also like