Burning Visible Images Onto CD-Rs With Data (beta)

189,319

141

112

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.

Attachments

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.

Recommendations

1 68 4.2K
16 1.0K
23 2.5K
183 12K

• Block Code Contest

Hi all,

I've been trying to do this for a long time and wanted to share my results:
the photo shows a view of the clouds on Earth from space

Hey
would love to know more as well. It seems like there isnt anybody else who managed such great results. Ill have to write something like a thesis in a few months and this could be a really nice theme for it. But i dont want to write about a project that i cant finish or even try.
Have you wrote some python/ C or whatever free language program that converts images to a burnable file on CDs or DVDs or did you make a whole driver that takes an image and physically burns the image onto the surface?
Or just tell me how have you done it.
Thanks
Regards
MD

Hello.

1- Which program/code did u use for this work?

2- How did u control the CD writer to pattern onto the CD.

3- Are all CD drivers or CD's suitable for this work?

Thanks.

I am trying to burn many rings on a CD to make a very coarse diffraction grating of 95 lines per millimeter.

If I get something I'll post an Instructable. The rings on the CD are to make a spectrometer that spreads out very long wavelength infrared energy. There is a big CO2 absorption band down there.

It is related to global warming. Here is my blog on the subject:

http://www.lowco2america.com/

Linux has a yes command that can make big files of a test character. Use that to make a 700 megabyte CD. See what it looks like.

Hello.

Did u get any results? If u did can u share ur experience?

Thanks.

This sounds like a very fascinating project.

If I could find out details about how DVD data is written, i could probably hack out something in Python that will convert an image to a data file that can be written to a DVD, since a DVD might give better resolution than a CD (my excuse is i got a bunch of blank DVDs on hand but no CDs). I would love to see this project pursued more.

i'd love to see this project come out of beta, it's a genius idea

HIIIIIIIIIIIIIIII, I found something cool out i dont know how it works though or how you would use it. 1. in microsoft paint make an image you like 2. save it to desktop 3. go to note pad 4. go to open and click all files then find and open it 5. it should come out in a very long pattern with a lot of y's 6. figure out some way to write that to the cd I cant really do this so if someone could please post a "REPLY" to this comment!! thanks!! - ;)

interesting....save as .dat....then burn as data cd with nero.interesting.

What you saw in MS Paint is just notepad trying to read what is really a series of hexadecimal numbers, for example:
if FF is white, 00 is black, and 01 means to go to the next line,
FF00FF0100FF00010000000100FF00
represents a small image of the letter A. This only indicates lines of black and white, so what you see here is already being used by the program.

P.S. That string of numbers works as follows:
FF00FF0100FF00010000000100FF00
which becomes this when splitting bytes apart with spaces:
FF 00 FF 01 00 FF 00 01 00 00 00 01 00 FF 00
then, converting 01 to a new line, 00 to #, and FF to a space:
` # # ##### #`
and you should be able to read the letter in that.

TUTORIAL ON HOW TO CONVERT MATLAB TO EXE http://www.onecore.net/howtocreate-standalone-executable-for-matlab-file.htm

if you ever got this algorithm down, you probably could make the whole disk an image - you would need to calculate the write pitch, the spacing, and the rough location of every bit on the disk, but it would be possible. I guess you'd have to look at how the FAT writes everything to the disk, each bit position on the disk could potentially be a pixel. Sounds like a lot of work, but it could be cool if you could get it to work.

ok i have all the codes i got matlab, and i have my monochrome image with the right dimensions, what do i do with the image? dont i have to put a link to it somewhere?? im so confused

How can I get this to work with octave? I don't and never will own Matlab, so I need to run it in octave, anyone know how? Or maybe it could be rewritten in C?

Figured it out, but it doesn't work:

octave:1> img2cd('logo.gif')
n128sec = 1
error: invalid row index = 83
error: invalid column index = 142
error: evaluating binary operator `<' near line 176, column 25
error: if: error evaluating conditional expression
error: evaluating if command near line 176, column 5
error: evaluating for command near line 174, column 3
error: evaluating for command near line 156, column 1
error: called from `img2cd' in file `/home/pabs/img2cd.m'

Any idea how to fix this?