Just show the idea for gray level image. RGB image is in similar way. It takes the following steps:
- DCT conversion and create a 1D matrix
- Sort elements of the matrix from the highest to the smallest and get the indices list
- Choose the highest N elements
- Inverse DCT
dvalue=imread('map.bmp');
dvalue = double(dvalue)/255;
dvalue = rgb2gray(dvalue);
img_dct=dct2(dvalue);
img_pow=(img_dct).^2;
img_pow=img_pow(:);
[B,index]=sort(img_pow);%no zig-zag
B=flipud(B);
index=flipud(index);
compressed_dct=zeros(size(dvalue));
coeff = 20000;% maybe change the value
for k=1:coeff
compressed_dct(index(k))=img_dct(index(k));
end
im=idct2(compressed_dct);imwrite(im, 'maptemp2.bmp')
or use 'im2double' to change unit8 image to double
ReplyDeletecan you tell me program flow?
Deletei think the flipud are not required
ReplyDeleteuse instead sort(var,'descend');
i think the flipud are not required
ReplyDeleteuse instead sort(var,'descend');
is it the entire code for implementing dct for video compression........
ReplyDeletereply on sargam86@gmail.com
do you anyone have matlab code for shape adaptive discrete cosine transform????
ReplyDeletemail me on vairam_mit@yahoo.co.in
will try this code..
ReplyDeletethank you^^
hi i need a code for feature extraction usin DCT for fingerprint recognition
ReplyDeletei need dct code for vedio compression........
ReplyDeleteplz mail it on tshank30@gmail.com
thanks...
I want to extract DCT coefficient for an image in matlab?? how to do that???
ReplyDeleteI am navya,
ReplyDeleteIf you have mini project full source code,document please mail me friend.
my mail id was navyanali64@gmail.com.
Kindly please reply me
thanks
hi navya if u want mini matlab project then mail me
Deletedeepeshrawat987@gmail.com
or visit
http://deepeshrawat987.blogspot.in/
do anyone knw the code for image compression and decompression.. plss mail me friends
ReplyDeletemy mail id swathireddi7@gmail.com
do reply me
I need code for Mp3 compression using MDCT
ReplyDeleteI need code for Mp3 compression using MDCT.Plz mail me friends.My mail ID is induks15@gmail.com
ReplyDeleteanyone can send code for 2d-dct in matlab pls its very urgent
ReplyDeletei need dct matlab code for image compression.. plz mail it on aartigdverma@yahoo.com
ReplyDeletei need dct matlab code..plz mail it to kshahid000@gmail.com
ReplyDeleteclear all;
Deletep=imread('arez.jpg');
a=imresize(p,[150,150]);
%DCT
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>60)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,1);
%imshow(Z);
imshow(uint8(K));
title('70% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>100)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,2);
%imshow(Z);
imshow(uint8(K));
title('50% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>140)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,3);
%imshow(Z);
imshow(uint8(K));
title('30% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>180)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,4);
%imshow(Z);
imshow(uint8(K));
title('10% compression DCT');
Hi, I need dct matlab code for image compression.. plz mail it on "ahmadelect@gmail.com" ; Thanks
ReplyDeleteclear all;
Deletep=imread('arez.jpg');
a=imresize(p,[150,150]);
%DCT
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>60)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,1);
%imshow(Z);
imshow(uint8(K));
title('70% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>100)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,2);
%imshow(Z);
imshow(uint8(K));
title('50% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>140)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,3);
%imshow(Z);
imshow(uint8(K));
title('30% compression DCT');
Z(:,:,1)=dct2(a(:,:,1));
Z(:,:,2)=dct2(a(:,:,2));
Z(:,:,3)=dct2(a(:,:,3));
for i=1:100
for j=1:100
if((i+j)>180)
Z(i,j,1)=0;
Z(i,j,2)=0;
Z(i,j,3)=0;
end
end
end
K(:,:,1)=idct2(Z(:,:,1));
K(:,:,2)=idct2(Z(:,:,2));
K(:,:,3)=idct2(Z(:,:,3));
subplot(2,4,4);
%imshow(Z);
imshow(uint8(K));
title('10% compression DCT');
I am doing project in video compression... I had a code but i got an error..Anyone help me to rectify the error in the code..If anyone interested pls contact me in this id angelicammu90@gmail.com
ReplyDeletei need dct matlab code for medical image compression.. plz mail it on ismail.maulood@gmail.com
ReplyDeletefor matlab image mini project such as noise filter visit
ReplyDeletehttp://deepeshrawat987.blogspot.in/