Sunday, 19 July 2015

MATLAB PROGRAM FOR DCT OF IMAGE



/*MATLAB PROGRAM FOR DCT OF IMAGE*/

clear all
clc
x=imread('cameraman.tif');
subplot(2,1,1)
imshow(x)
title('Original image')
x=double(x);
[m n]=size(x);
const=sqrt(2/n);
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;
c(u+1,v+1)=const*cos((pi*(a+1)*u)/(2*n));
end
end
end
f=c*x*c'
subplot(2,1,2)
imshow(f)
title('DCT IMAGE')

OUTPUT

No comments:

Post a Comment