Introduction: Burning Visible Images Onto CD-Rs With Data (beta)
By carefully choosing the right 1s and 0s to burn to a CD, it is possible to burn visible images on normal CD-Rs. These images rely on the fact that the 1s and 0s created by pits in the CDs surface reflect light differently.
Step 1: Learn How CDs and CD-Rs Work
Data on a CD, or any optical media, is stored as a sequence of pits of varying lengths. To be precise, a 1 is represented by the change from pit to no-pit or the change from no-pit to pit, and a 0 is represented by no change in height (pit to pit or no-pit to no-pit). The pits and no-pits reflect different amounts of light; thus it is possible to draw images on CDs by appropriately arranging these 1s and 0s.
How do you arrange the 1s and 0s? It helps to know that the data is written along a spiral that starts from the center of the CD and spirals outward in a clockwise direction. The length of each bit is a fairly precise value (more on this later), and the pitch of the spiral, or the distance between successive spirals, is also a fairly precise value. Thus, using some math and some guesswork, it is possible to create a mapping from the nth bit in your data to an x,y coordinate.
Now we really have to look under the hood of CD data storage to figure out how to tell the CD writer to write a 0 or 1 for the nth bit. Data is organized as a sequence of sectors, each of which is 2352 bytes long. The data within each sector is organized in a particular way depending on what type of CD your are dealing with (data, audio, etc...). The most "raw" type of organization is known as "mode 2." Mode 2 does away with many of the nice things about CDs like error correction, but it gives us the most control over the bits. In a mode 2 sector, the first 12 bytes contain "syncing" data and the next 4 contain specific information about the sector. These bytes cannot be changed at the software level. (Maybe it is possible to write a driver that could change these?) The next 2336 bytes are free to be anything though. If this were all that happened to the data, our job would be easy. Unfortunately, there's a lot more data manipulation before the data actually gets written to the CD.
First, the data in each sector is "scrambled" by which we mean it is run through some math function which is supposed to "whiten" the data (i.e. keep the average height of the data on the CD half-way between pit and no-pit).
Second, the data is sent through a CIRC encoder, which applies some error correction codes.
Finally, the data is sent though an eight-to-fourteen modulator (EFM). This maps each 8-bit byte to a 14-bit sequence. This is to prevent long sequences of 0's (no change in height) which are hard for the CD drive to read.
The point is: drawing pictures on CDs is possible, so it should be done.
For a more complete (but still at some times cryptic) explanation of CDs, check out the freely available ECMA-130 specification.
Step 2: Convert a Picture to Data
Here are the MATLAB programs that I use to convert an image to a data file.
Use the freely available cdrecord program in "mode 2" to burn the data to a CD-R.
Step 3: Calibrate Your CD-Rs
Each brand (or maybe even set) of CD-Rs has slightly different properties such as track pitch or linear scanning velocity. Before successfully drawing a picture, it is necessary to determine what these values are. To do this, create a data file which represents a radial line. Draw this to the CD-R, and you may get a spiral. Now it's time for the guesswork. Try to change the values, to convert this spiral back into a radial line.
Step 4: Draw a Picture!
Here I've shown a CD-R with a picture of two people kissing burned on it. It's a little hard to discern because I haven't completely calibrated this CD-R yet.