#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    I live in Petaling Jaya, Malaysia
    Posts
    1
    Rep Power
    0

    Question Converting Digital Images to Binary Codes


    There are several steps that are involved in this process:
    Imagine that;

    1) I took a digital photo of a car plate number.
    2) I store it into the computer, setting my own matrix size (of pixels) and grayscaling it.

    Now comes the part that I haven't been able to figure out yet. How do I convert the pixels (or the bytes in the pixels) into the coresponding binary codes? I'm supposed to come up with a program (C/C++) to do the conversion but I don't know what I'm supposed to work on here! I've heard something vague about 'hex codes'? How do I 'disect' the individual pixels to code them? I'm also at a loss about whats the best type (bmp, jpeg, etc.) to use...

    I really can't seem to find the specific answers from the web, so I hope a kind soul out there can give me a few pointers to work with? Thanks a lot!!!
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    First, you need to understand that all data is just a bunch of bits that only have meaning in the context of the programmer and user. Second, you need to understand what image compression does for (and against) you. A bmp file is uncompressed meaning that each pixel is represented in the file (which is only an image file because you decide it is). A jpeg file has had a compression algorithm (which, BTW, causes a loss of data!) run on it and is completely incomprehensible without the appropriate decompression algorithm (might as well be a random collection of bits otherwise). (A gif file, BTW, uses a different form of compression.) If you work with a compressed file, you must first decompress it before you can work with the bits. Most libraries (to my knowledge C and C++ lack any standard libraries for working with images, though Java has several) will allow you to access each pixel of the image. Using those library functions you can retrieve the bits that code for each pixel in various formats. As for retrieving it in 'binary' format, what other kind of format do you think the data is stored in? It is all binary, even the ASCII data is binary, it is just a series of bits that we all agree on are in a certain format. There are lots of books and web pages that are devoted to image data, I am sure you are just picking poor words in your attempts to search.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

IMN logo majestic logo threadwatch logo seochat tools logo