Like Tree2Likes
  • 2 Post By oogabooga

Huffman decoding

This is a discussion on Huffman decoding within the C Programming forums, part of the General Programming Boards category; Hi. I am new to the board and no absolutely nothing about Huffman coding. I am actually trying to solve ...

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    3

    Huffman decoding

    Hi. I am new to the board and no absolutely nothing about Huffman coding. I am actually trying to solve a geocaching puzzle where there is a Huffman code I nee to decode. I have no idea what it is or how to solve it. If anyone can be of assistance I would greatly appreciate it. Below is the information I was able to find. Thanks.

    http://regex.info/exif.cgi?url=http%...nd%3D0.9374906

  2. #2
    Registered User
    Join Date
    Apr 2013
    Posts
    1,263
    You'd need to know the table for the Huffman code. Generally the leading few bits of a Huffman Code determine the total number of bits in a single code. Some implementations, such as zip compression utilities, may optionally create and use a dynamically created Huffman code table, and include that table as part of the "header" in a compressed file. Wiki article:

    Huffman coding - Wikipedia, the free encyclopedia

  3. #3
    Registered User
    Join Date
    Aug 2013
    Posts
    3
    Quote Originally Posted by rcgldr View Post
    You'd need to know the table for the Huffman code. Generally the leading few bits of a Huffman Code determine the total number of bits in a single code. Some implementations, such as zip compression utilities, may optionally create and use a dynamically created Huffman code table, and include that table as part of the "header" in a compressed file. Wiki article:

    Huffman coding - Wikipedia, the free encyclopedia

    I'm sorry, but everything you posted is complete jibberish to me. I am not computer literate at all, but thanks for your reply. I stumbled to get the info I got from the photo that I need to decode. Here is the original photo.

    Name:  CBLSC.png
Views: 91
Size:  127.6 KB

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    The huffman coding is used in the image compression and has nothing to do with the metadata.
    If you're trying to "decode" the hex string on the page you linked, note that it's just ascii.
    20 is a space.
    30 is a zero.
    31 is a one.
    So your data is apparently:
    Code:
    01001110 00110100 00110000 00100000 00110001 00110100 00101110 00110111 00110001 00110000 00100000 01010111 00110111 00110101 00100000 00110011 00111001 00101110 00110000 00110111 00110001
    Which, interpreted a single byte at a time (and in decimal) is:
    Code:
    78 52 48 32 49 52 46 55 49 48 32 87 55 53 32 51 57 46 48 55 49
    Interpretting again as ascii gives:
    Code:
    N 4 0   1 4 . 7 1 0   W 7 5   3 9 . 0 7 1
    which I believe is what you're looking for.
    dvargo1226 and Salem like this.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Registered User
    Join Date
    Aug 2013
    Posts
    3
    Yes, yes! That is what I was looking for. I was going nuts trying to understand all of this coding stuff and getting nowhere. Thanks so much for your quick reply.

  6. #6
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    The quick-and-dirty program I used to decode the info:
    Code:
    #include <stdio.h>
    #include <ctype.h>
    
    
    int main(void) {
    
    
    	int c1, c2, n = 0;
    
    
    	while ((c1 = getchar()) != EOF) {
    
    
    		if (isspace(c1)) continue;
    
    
    		c2 = getchar();
    
    
    		if (c1 == '2') {
    			printf("%c", n);
    			n = 0;
    		}
    		else {
    			n <<= 1;
    			if (c2 == '1') n++;
    		}
    	}
    
    
    	return 0;
    }
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Huffman
    By amap100 in forum C Programming
    Replies: 3
    Last Post: 12-29-2012, 07:25 PM
  2. Decoding program help
    By 987654 in forum C++ Programming
    Replies: 3
    Last Post: 10-17-2010, 06:17 AM
  3. Decoding
    By jugs in forum C Programming
    Replies: 2
    Last Post: 10-27-2009, 02:20 PM
  4. Decoding
    By jk81 in forum C Programming
    Replies: 4
    Last Post: 11-12-2002, 10:24 PM
  5. Huffman compression
    By SMurf in forum C Programming
    Replies: 2
    Last Post: 09-01-2001, 07:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21