Donnerstag, 14. März 2013

2-D Inverse Discrete Cosine Transform


Consider the result obtained after DCT. (Check 2d-DCT )
Apply Inverse Discrete Cosine Transform to obtain the original Image.




MATLAB CODE:

%2-D INVERSE DISCRETE COSINE TRANSFORM
%PREALLOCATE THE MATRIX
A=zeros(size(B));
Temp=zeros(size(B));
[M N]=size(B);

x=1:M;
x=repmat(x',1,N);
y=repmat(1:N,M,1);

figure,
imshow(log(abs(B)),[]);colormap(jet);title('After DCT');







for i=1:M
    for j = 1: N
   
        if(i==1)
          AlphaP=sqrt(1/M);
        else
          AlphaP=sqrt(2/M);
        end
       
        if(j==1)
          AlphaQ=sqrt(1/N);
        else
          AlphaQ=sqrt(2/N);
        end
                 
        cs1=cos((pi*(2*x-1)*(i-1))/(2*M));
        cs2=cos((pi*(2*y-1)*(j-1))/(2*N));
        Temp=B.*cs1.*cs2*AlphaP*AlphaQ;
              
          A(i,j)=sum(sum(Temp));
    end
end
%OUTPUT
figure,
imshow(abs(A),[0 255]);title('Image after IDCT');












Keine Kommentare:

Kommentar veröffentlichen