CD matrix barcode scanning

This guide supplements the article on CD matrix barcodes.

Basic scanning technique

Start with a large (600x600 or better) scan or photo of the matrix area. Make sure it is centered and evenly cropped square. It helps if the barcode does not cross the "12 o'clock" (top center) boundary of the original image.

Convert polar to rectangular coordinates. For example, in Photoshop: Filter > Distort > Polar Coordinates > Polar to Rectangular > OK.

Invert colors. For example, in Photoshop: Image > Adjustments > Invert (Ctrl+I or Option+I)

If needed, improve contrast so the barcode is very dark and the background very light. For example, in Photoshop: Image > Adjustments > Levels (Ctrl+L or Option+L) > black eyedropper > click on grey part of the bars to make them black, then choose the white eyedropper and click on the background to make it white. Then click OK.

Attempt scanning. If it still isn't scannable, you may need to further enhance contrast, desaturate color, elongate the bars, or otherwise do what you have to in order to get the bars stand out and be in a straight line.

Errors

Here is an example of an image which is not centered and evenly cropped:

The barcode ends up not being in a straight line:

This image also is a little bit too small to get a reliable scan. However, it is not hopeless! Enlarge it, invert colors, adjust contrast. There is now an area which the scanner can read (in the green box):

However, this still is not ideal; it can incorrectly scan as 0Q96. The grey bars in the middle too light. Adjust contrast some more:

Now this scans correctly as 05296. Hooray!

Manual verification

One way to manually verify is to create a known good barcode for your scanned result, and see if it matches the actual photo.

For this, you can use an online barcode generator or barcode generating software.

Or, there are free barcode fonts which you can use with your favorite text editor, if it lets you choose a very large point size. Using the font, type a code surrounded with standard boundary characters (asterisks), like *05296*. The result will be something like this (this is using a free Code 39 font):

The relative widths of thin to thick bars and the whitespace between the encoded symbols probably will not perfectly match the barcode on the disc, but you can still do a visual comparison and confirm that the thick and thin bars appear in the same order in both images (you may need to rotate one of them 180 degrees first):