matlab - Huffman coding for jpeg compression -
matlab - Huffman coding for jpeg compression -
i m working on jpeg compression m using huffman coding , decoding,i dnt want utilize inbuilt function (huffmandict,huffmanencdo,huffmandeco) instead of inbuilt function coding can use.here encoded out of runlength coding.
head=0; pos=0; s_=size(encoded); i=1:s_(2) if (pos~=0) s=size(head); f=0; k=1; while (f==0 && k<=s(2)) if (encoded(i)==head(k)) f=1; end; k=k+1; end; else f=0; end; if (f==0) pos=pos+1; head(pos)=encoded(i); end; end; %compute probability symbols% s_h=size(head); count(1:s_h(2))=0; i=1:s_h(2) j=1:s_(2) if (encoded(j)==head(i)) count(i)=count(i)+1; end; end; end; count=count./s_(2); %sort accordng maximum number% i=1:s_h(2)-1 j=i+1:s_h(2) if (count(j)>count(i)) t1=count(i); count(i)=count(j); count(j)=t1; t1=head(i); head(i)=head(j); head(j)=t1; end; end; end; [dict,avglen] = huffmandict(head,count); % create dictionary. comp = huffmanenco(encoded,dict); % encode data. end end decode=huffmandeco(comp,dict);
matlab image-processing huffman-coding
Comments
Post a Comment