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
댓글 수: 1
Walter Roberson
2013년 1월 25일
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 ?
답변 (0개)
커뮤니티
더 많은 답변 보기: Power Electronics Community
참고 항목
카테고리
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!