Vous êtes sur la page 1sur 9

Image Compression Using the

Discrete Cosine Transform

Tran The Linh


Nguyen Duy Tien
Ngo Duc Thanh
Image Compression Using the DCT
Image Compression Using the Discrete
Cosine Transform
• Abstract
The discrete cosine transform (DTC) is a technique
for converting a signal into elementary frequency
components. It is widely used image compression.
Here we develop some simple functions to
compute the DCT and compress images.
These functions illustrate the power of Matlab in
the prototyping of image processing algorithms

Image Compression Using the DCT


The one-Dimensional Discrete
Cosine Transform
• The One-Dimensional Discrete Cosine Transform
The Discrete Cosine Transform of a list of n real
number x(n), n=1…N, is the list of length N given
by: N
 (2n 1)(k 1)
y(k)  w(k) x(n)cos( ) (k  1...N)
n1 2N
where:
 1
 if k  0
 N
w(k )  
 2
otherwise
 N
Image Compression Using the DCT
The one-Dimensional Discrete
Cosine Transform
• The example
x=50sin(2pi*t/40);
X=dct(x);
plot(t,x,t,X);legend('x(t)',DCt(x));

Image Compression Using the DCT


The one-Dimensional Discrete
Cosine Transform
• The example
Find how many DCT coefficients represent 99% of the
energy in a sequence:
x = (1:100) + 50*cos((1:100)*2*pi/40);
X = dct(x); [XX,ind] = sort(abs(X));
ind = fliplr(ind); i = 1;
while (norm([X(ind(1:i))
zeros(1,100-i)])/norm(X)<.99)
i = i + 1;
end
% i = 3

Image Compression Using the DCT


The Two-Dimensional Discrete
Cosine Transform
• The One-Dimensional DCT is useful in
processing on dimensional signals such as
speech waveforms. For analysis of two-
dimensional (2D) signal such as images, we
need a 2D version of the DCT. for an matrix.
The DCT-2D is computed in a simply way: The
DCT-1D is applied to each row of x and the to
each column of the result.

Image Compression Using the DCT


The Two-Dimensional Discrete
Cosine Transform
• Thus, the transform of x given by:
 (2m 1) p
M 1 N 1
 (2n 1)q 0  p  M 1
Bpq  pq Amn cos( )cos( ) 
m0 n0 2M 2N 0  q  N 1
where:
 1  1
 , p0  ,q  0
 M  N
p   and q  
 2  2
,1  p  M 1 ,1  q  M 1
 M  N

Image Compression Using the DCT


The Two-Dimensional Discrete
Cosine Transform
• The example
RGB = imread(‘hnen.bmp');
I = rgb2gray(RGB);
J = dct2(I);
imshow(log(abs(J)),[]),
colormap(jet(64)), colorbar;

Image Compression Using the DCT


The Two-Dimensional Discrete
Cosine Transform
Now set values less than magnitude 10 in the DCT matrix to
zero, and then reconstruct the image using the inverse DCT
function idct2.
J(abs(J) < 10) = 0;
K = idct2(J);
imshow(I) figure,
imshow(K,[0 255]);

Image Compression Using the DCT

Vous aimerez peut-être aussi