huffman-code

Storing Probability table during text compression

主宰稳场 提交于 2019-12-08 04:14:30
问题 I am doing a project where I compare different types of Text compression methods such as Huffman and Arithmetic for both static and adaptive form. I make a probability table for both using the number of occurrence of each letter in the text. Now, for adaptive form, the receiver does not need the Probability table but for the static form, we need to transmit this probability table as well to the receiver for decoding the message. Now this storing of the table will need some extra bits, which

Efficient compression and representation of key value pairs to be read from 1D barcodes

折月煮酒 提交于 2019-12-08 00:58:56
问题 I'm currently writing an application for Windows Mobile which needs to be able to pick up key value pairs from 1D barcodes (configuration settings). The less barcodes need to be scanned, the better. Sample input: ------------------------------ | Key | Value | ------------------------------ | 12 | Söme UTF-8 Strîng | | 9 | & another string | ------------------------------ I thought of the following algorithm: 1. Concat the key value pairs and encode the values with Base64 So we would get

How can I print a bit instead of byte in a file?

你说的曾经没有我的故事 提交于 2019-12-07 14:37:33
问题 I am using huffman algorithm to develop a file compressor and right now I am facing a problem which is: By using the algorithm to the word: stackoverflow, i get the following result: a,c,e,f,k,l,r,s,t,v,w = 1 time repeated o = 2 times repeated a,c,e,f,k,l,r,s,t,v,w = 7.69231% and o = 15.3846% So I start inserting then into a Binary Tree, which will get me the results: o=00 a=010 e=0110 c=0111 t=1000 s=1001 w=1010 v=1011 k=1100 f=1101 r=1110 l=1111 which means the path for the character in the

Parsing jpeg file, SOS marker

允我心安 提交于 2019-12-07 02:35:37
问题 I'm having problem with parsing jpeg file. When I hit SOS (start of scan) marker, there are few bytes which meaning I don't understand. In picture bellow, after SOS marker, there are 2 bytes for header length (Ls part on the picture). But what the rest of data on picture mean (for example Ns, Cs1 etc....), and where the pure data starts? 回答1: Cs1 is a components selection index, This refers back to the SOF section (where horizontal and vertical sampling factors are specified) Td1 is the DC

Storing Probability table during text compression

蓝咒 提交于 2019-12-06 16:32:09
I am doing a project where I compare different types of Text compression methods such as Huffman and Arithmetic for both static and adaptive form. I make a probability table for both using the number of occurrence of each letter in the text. Now, for adaptive form, the receiver does not need the Probability table but for the static form, we need to transmit this probability table as well to the receiver for decoding the message. Now this storing of the table will need some extra bits, which should be taken into account while comparing. So my question here is: What is the best solution for

Decoding a Huffman code with a dictionary

∥☆過路亽.° 提交于 2019-12-06 14:52:56
问题 I need to decode a Huffman code I coded with my program using a file containing the translation beetween ASCII and Huffman bits. I have already a dictionary in the progam from "codes" to ASCII like this one: {'01110': '!', '01111': 'B', '10100': 'l', '10110': 'q', '10111': 'y'} I created the function: def huffmanDecode (dictionary, text) : That needs the dictionary and the code. I have tried searching the text for key in the dictionary and using both the replace method form string and the sub

Optimal Huffman Code for Fibonacci numbers

北慕城南 提交于 2019-12-06 14:36:06
What is an optimal Huffman code for the following characters whose frequencies are the first 8 Fibonacci numbers: a : 1, b : 1, c : 2, d : 3, e : 5, f : 8, g : 13, h : 21? Generalize the case to find an optimal code when the frequencies are the first n Fibonacci numbers. This is one of the assignment problems I have. I'm not asking for a straight answer, just for some resources. Where should I look to put the pieces together to answer the questions? Read - http://en.wikipedia.org/wiki/Huffman_coding - In particular, pay attention to the phrase "A binary tree is generated from left to right

Efficient compression and representation of key value pairs to be read from 1D barcodes

◇◆丶佛笑我妖孽 提交于 2019-12-06 13:24:12
I'm currently writing an application for Windows Mobile which needs to be able to pick up key value pairs from 1D barcodes (configuration settings). The less barcodes need to be scanned, the better. Sample input: ------------------------------ | Key | Value | ------------------------------ | 12 | Söme UTF-8 Strîng | | 9 | & another string | ------------------------------ I thought of the following algorithm: 1. Concat the key value pairs and encode the values with Base64 So we would get something like 12=U8O2bWUgVVRGLTggU3Ryw65uZw==&9=JiBhbm90aGVyIHN0cmluZw== 2. Use Huffman encoding to

Huffman compression algorithm

一个人想着一个人 提交于 2019-12-06 07:42:16
问题 I've implemented file compression using huffman's algorithm, but the problem I have is that to enable decompression of the compressed file, the coding tree used, or the codes itself should be written to the file too. The question is: how do i do that? What is the best way to write the coding tree at the beggining of the compressed file? 回答1: There's a pretty standard implementation of Huffman Coding in the Basic Compression Library (BCL), including a recursive function that writes the tree

How to write Huffman coding to a file using Python?

半世苍凉 提交于 2019-12-06 07:21:56
I created a Python script to compress text by using the Huffman algorithm. Say I have the following string: string = 'The quick brown fox jumps over the lazy dog' Running my algorithm returns the following 'bits': result = '01111100111010101111010011111010000000011000111000010111110111110010100110010011010100101111100011110001000110101100111101000010101101110110111000111010101110010111111110011000101101000110111000' By comparing the amount of bits of the result with the input string, the algorithm seems to work: >>> print len(result), len(string) * 8 194 344 But now comes the question: how do