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 ?
jpeg dc coefficient coding
2 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
社区
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Denoising and Compression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!