jpeg dc coefficient coding

2 visualizzazioni (ultimi 30 giorni)
mamatha
mamatha il 25 Gen 2013
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 Commento
Walter Roberson
Walter Roberson il 25 Gen 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 ?

Accedi per commentare.

Risposte (0)

Community

Più risposte nel  Power Electronics Control

Categorie

Scopri di più su Denoising and Compression in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by