Thursday, 29 September 2016

Program for Discrete Cosine Transform using Matlab

Program for Discrete Cosine Transform using Matlab


The DCT, and in particular the DCT-II, is often used in signal and image processing, especially for lossy compression, because it has a strong "energy compaction" property in typical applications, most of the signal information tends to be concentrated in a few low-frequency components of the DCT.
The discrete cosine transform (DCT) represents an image as a sum of sinusoids of varying magnitudes and frequencies. The dct2 function computes the two-dimensional discrete cosine transform (DCT) of an image. The DCT has the property that, for a typical image, most of the visually significant information about the image is concentrated in just a few coefficients of the DCT. For this reason, the DCT is often used in image compression applications. For example, the DCT is at the heart of the international standard lossy image compression algorithm known as JPEG.

Program:


clc;
x=imread('D:\Flower.jpg');                     %Image Path
a=rgb2gray(x);
figure(1);
imshow(a);
[M N]=size(a);
const=sqrt(2/N);
for u=0:1:N-1
    for v=0: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
final_dct=c*a;
figure(2);
imshow(final_dct);


OUTPUT:

http://programixs.blogspot.in/

Download program with output




No comments:

Post a Comment