huffman

need help on how to encode words using huffman code

how do you encode words using the huffman code such as NEED ...

How best to search binary data for variable length bit strings?

Can anyone tell me the best way to decode binary data with variable length bit strings in java? For example: The binary data is 10101000 11100010 01100001 01010111 01110001 01010110 I might need to find the first match of any of the following 01, 100, 110, 1110, 1010... In this case the match would be 1010. I then need to...

How to create Huffman tree from FFC4 (DHT) header in jpeg file?

I thought I could work this one out myself but I don't seem to be moving forward at all. Ok, the background: I need to create a Huffman tree of codes from the information provided by the FFC4, DHT (Define Huffman Table) header in a jpg file. The DHT header defines the Huffman table in this way: 1) A series of 16 bytes. Each byte defin...

huffman encoding

hiii... I am trying to implement the huffman algorithm for compression.. for that I have to write bits of variable length to a file.. is there any datatype in c++ to store bits in a file???? i tried using bitset<8> but its size is 4 bytes..so i cant use it since i am implementing compression..please help.. ...

Efficient way of storing Huffman tree

I am writing a Huffman encoding/decoding tool and am looking for an efficient way to store the Huffman tree that is created to store inside of the output file. Currently there are two different versions I am implementing. This one reads the entire file into memory character by character and builds a frequency table for the whole docum...

Efficient Huffman tree search while remembering path taken

As a follow up question related to my question regarding efficient way of storing huffman tree's I was wondering what would be the fastest and most efficient way of searching a binary tree (based on the Huffman coding output) and storing the path taken to a particular node. This is what I currently have: Add root node to queue while q...

Huffman compression algorithm.

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? ...

Need help on BMP to JPEG conversion

I'm writing a C++ program to convert a BMP image into a JPEG. Here's the basic algorithm I'm trying to follow: Convert RGB color space to Y,Cb,Cr.. Down sample Cb and Cr by 2 (that means for each square block of 2*2 there is 4 different Y value but 1 Cb and 1 Cr value Apply DCT to data units of each 8*8 pixels... Then apply quantizati...

Burrows-Wheeler Move to Front

For a project that I'm working on, I need to implement Burrows-Wheeler's MoveToFront transformation in O(n) space. For some reason, though, my code works on most values that I throw at it, but not all. My implementation looks something like this: public byte[] transform (byte[] input) { if (input.length == 0) return input;...

Input string compressed as string

Hi, I want to compress/transform a string as new string. i.e.: input string: USERNAME/REGISTERID output string after compress: <some-string-in-UTF8-format> output string after decompress: USERNAME/REGISTERID There are some compress or hash method for this transformation? I prefer some solution using Java or an algorithm with ...

Decoding a JPEG Huffman block (table)

The following block is nested by Huffman block markers -HUFF---------------------------------------------------------------------0084- 10 0 1 2 4 3 4 6 5 6 8 a 9 4 2 3 0 1 2 11 0 3 4 21 5 12 31 6 41 51 61 13 22 71 81 91 a1 14 32 b1 d...

Segmentation Fault - Adaptive Huffman Tree

I am trying to implement the adaptive huffman code, but while trying to build the tree i get a segmentation fault when executing the code at line "currentNYT->lchild = newNYT;" in addnode() function. Could anyone please help me out? It might be something simple i'm not aware of. didn't use C for a while now. //variable and type declara...

Data Compression

i have a task to compress a stock market data somehow...the data is in a file where the stock value for each day is given in one line and so on...so it's a really big file. Eg, 123.45 234.75 345.678 889.56 ..... now the question is how to compress the data (aka reduce the redundancy) using standard algorithms like Huffman or Arith...

Writing files in bit form to a file in C

i am implementing the huffman algorithm in C. i have got the basic functionality down upto the point where the binary codewords are obtained. so for example, abcd will be 100011000 or something similar. now the question is how do you write this code in binary form in the compressed file. i mean if i write it normally each 1 and 0 will be...

Extended Huffman code

Hello, I have this homework: finding the code words for the symbols in any given alphabet. It says I have to use binary Huffman on groups of three symbols. What does that mean exactly? Do i use regular Huffman on [alphabet]^3? If so, how do I then tell the difference between the 3 symbols in a group? ...

anyone know how to decode huffman tree?

is there better way than just go left or right based on the input digit 0 or 1? ...

How to decode huffman code quickly?

I have implementated a simple compressor using pure huffman code under Windows.But I do not know much about how to decode the compressed file quickly,my bad algorithm is: Enumerate all the huffman code in the code table then compare it with the bits in the compressed file.It turns out horrible result:decompressing 3MB file would need 6 ...

ASCII Text String Shortening

I am not really interested in security or anything of that nature, but I need some function(s) that allow me to "compress"/"decompress" a string. I have tried Base64, but that has a big issue with the size of the string, it makes it longer. I also know about this Huffman stuff, but that doesn't work either because it too makes it longer ...

Decoding a compressed short string; uncertain on compression used - Updated

Hi, I have a program that is compressing a string in an unknown way. I know a few inputs and the output produced, but I am not sure what is being used to compress the string. Here are my examples. (just 38 x a, no spaces or anything else) In: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Out: "21 1A A6 30 00" (just 32 x a) In: "aaaaaa...

I'm getting error C2664 on some I/O code.

void BinaryTree::InitializeFromFile(string Filename){ ifstream inFile; inFile.open(Filename, fstream::binary); if(inFile.fail()){ cout<<"Error in opening file "<<Filename; return; } for(int i=0;i<=255;i++) Freq[i]=0; char c; inFile.get(c); while(!inFile.eof()){ Freq[c] ++; inFile.get(c); } } HuffmanTree.cpp(...