jpeg dc coefficient coding

hi i am not understanding the code for dc coefficient encoding used in jpeg compression....the code given below.....can anybody help me out pls???????
this is the code
function b=jdcenc(x)
% Huffman encoding of DC coefficients in JPEG
% category c = floor(log2(abs(x)))+1
% append code is the binary representation of abs(x) if x>0
% of the 1's complement of bianry rep of abs(x) if x < 0
% first figure out category number
if x ==0,
%b=[0 1 0];
b=[0 0];
return % done
else
c = floor(log2(abs(x)))+1;
end
% Huffman table
tab=[2 0 0 0 0 0 0 0 0 0
3 0 1 0 0 0 0 0 0 0
3 0 1 1 0 0 0 0 0 0
3 1 0 0 0 0 0 0 0 0
3 1 0 1 0 0 0 0 0 0
3 1 1 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0 0
5 1 1 1 1 0 0 0 0 0
6 1 1 1 1 1 0 0 0 0
7 1 1 1 1 1 1 0 0 0
8 1 1 1 1 1 1 1 0 0
9 1 1 1 1 1 1 1 1 0];
tbl=tab;
b=tbl(c+1,2:tbl(c+1,1)+1);
tmp=int2bin(x,c);
% tmp is 1 by c+1 vector containing sign-mag
% representation of x, first bit is sign bit.
if tmp(1)==0, % if x > 0
b=[b tmp(2:c+1)];
elseif tmp(1)==1, % if x < 0
b=[b ones(1,c)-tmp(2:c+1)];
end

1 comentario

Walter Roberson
Walter Roberson el 25 de En. de 2013
Please be more specific about the part of the code that you do not understand. For example do you not understand what "tmp(2:c+1)" would mean in MATLAB ?

Iniciar sesión para comentar.

Respuestas (0)

Comunidades de usuarios

Más respuestas en  Power Electronics Control

Categorías

Más información sobre Denoising and Compression en Centro de ayuda y File Exchange.

Preguntada:

el 25 de En. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by