Image compression using DCT
Program:-
clear all;
close all;
clc;
x= imread('cameraman.tif');
[M N]=size(x);
figure(1);
imshow(x);
s= double(x);
for u=0:1:N-1
for
v=0:1:N-1
if
u==0
c(u+1,v+1)=1/sqrt(N);
else
a=(2*v)+1;
b=sqrt(2/N);
c(u+1,v+1)=b*cos(a*pi*u/(2*N));
end
end
end
F_DCT=c*s*c.';
I=uint8(F_DCT);
figure(2);
imshow(I);
Output :-
Image 1:-
Image compression using DCT (Image 1) |
Image compression using DCT (Image 2) |
0 comments:
If you have any doubts,please let me know