my own DCT2 and IDCT2 Solved
Afficher commentaires plus anciens
Hey guys i am trying to make my own DCT2 and IDCT2 for school but
i can't find any error -> this is how i checked that it is not working ( as i know when i will do B=DCT2(vector) and then C=IDCT2(B) C will equal vector)
( this is exacly for 8x8 blocks and is use in JPEG coder )
Here is photo what exactly i have to do
DCT


and here is code
% dct2
function [ F ] = doDCT2( v2 )
N=8;
F=zeros(N,N);
for u=0:1:N-1
for v=0:1:N-1
vC=getC(v);
uC=getC(u);
temp=0;
for x=0:1:N-1
for y=0:1:N-1
temp =temp+v2(u+1,v+1)*cos(((2*x+1)*pi*u)/16)*cos(((2*y+1)*pi*v)/16);
end
end
F(u+1,v+1)=vC*uC*(1/4)*temp;
end
end
end
%c(u)
function [ C ] = getC( N )
if N==0
C=1/sqrt(2);
else
C=1;
end
end
%IDCT2
function [ F ] = doIDCT2( v2 )
N=8;
F=zeros(N,N);
for u=0:1:N-1
for v=0:1:N-1
vC=getC(v);
uC=getC(u);
temp=0;
for x=0:1:N-1
for y=0:1:N-1
temp =temp+vC*uC*v2(u+1,v+1)*cos(((2*x+1)*pi*u)/16)*cos(((2*y+1)*pi*v)/16);
end
end
F(u+1,v+1)=(1/4)*temp;
end
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spectral Measurements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!