Dear all, I am looking for matlab source code for huffman encoding such as those used in JPEG... I hate C code since I guess I need 10x more time to modify it to suit my need; but with matlab code it is more understandable and modifiable... My need is to see a 16x16 picture block, if using Huffman encoding... needs how many bits....(need accurate bit counting, and do not want get the overhead of jpeg header file...) Please help me! Thanks a lot, -Walala
any matlab function/source code for huffman encoding
Started by ●November 21, 2003
Reply by ●November 28, 20032003-11-28
"walala" <mizhael@yahoo.com> schreef in bericht news:bplmuc$qo5$1@mozo.cc.purdue.edu...> Dear all, > > I am looking for matlab source code for huffman encoding such as thoseused> in JPEG... > > I hate C code since I guess I need 10x more time to modify it to suit my > need; but with matlab code it is more understandable and modifiable... > > My need is to see a 16x16 picture block, if using Huffman encoding...needs> how many bits....(need accurate bit counting, and do not want get the > overhead of jpeg header file...) > > Please help me! > > Thanks a lot, > > -Walala >no matlab functions here, however if you only need to know how many bits it would take with huffman codes, then you should not really compress the file. All you need to know is how many bits are needed to encode each (different) symbol. then the entire length of the encoded file (without headers, as you wanted) is given by: Entire_Length = 0; for (int i=0;i<256 (1); i++){ Entire_Length += occurences[i] * bit_length[i]; } in which: 1. bit_length[i] is the amount of bits needed to encode i; 2. occurences[i] is frequency of i; if you want to know how to get the amount of bits needed for a certain i, then i suggest using google ;-). jan
Reply by ●November 29, 20032003-11-29
"jdoms" <jandoms@hotmail.com> wrote in message news:5kOxb.48728$y62.1642603@phobos.telenet-ops.be...> > "walala" <mizhael@yahoo.com> schreef in bericht > news:bplmuc$qo5$1@mozo.cc.purdue.edu... > > Dear all, > > > > I am looking for matlab source code for huffman encoding such as those > used > > in JPEG... > > > > I hate C code since I guess I need 10x more time to modify it to suit my > > need; but with matlab code it is more understandable and modifiable... > > > > My need is to see a 16x16 picture block, if using Huffman encoding... > needs > > how many bits....(need accurate bit counting, and do not want get the > > overhead of jpeg header file...) > > > > Please help me! > > > > Thanks a lot, > > > > -Walala > > > > no matlab functions here, > > however if you only need to know how many bits it would take with huffman > codes, then you should not really compress the file. > All you need to know is how many bits are needed to encode each(different)> symbol. > then the entire length of the encoded file (without headers, as youwanted)> is given by: > > Entire_Length = 0; > for (int i=0;i<256 (1); i++){ > Entire_Length += occurences[i] * bit_length[i]; > } > > in which: > 1. bit_length[i] is the amount of bits needed to encode i; > 2. occurences[i] is frequency of i; > > if you want to know how to get the amount of bits needed for a certain i, > then i suggest using google ;-). > > jan >Hi, Jan, Thank you for your answer! I guess I can do what you talked about, but actually the ordinary Huffman coding is a little different than that in JPEG... I want to know the exact bits spended for a 8x8 block in a JPEG... Do you have any idea how to do that? Thanks a lot, -Walala