As you already know, a barcode is a series of alternating black and white stripes that can be found on almost every item sold in stores. The relative widths of the bars encode information, be it a string of numbers, letters, or even an image. Probably the most familiar barcode is the Universal Product Code (UPC), which is used on grocery items to encode a 10 digit number. (A UPC code actually has 12 digits, but for simplicity we ignore the first digit, which identifies the type of item, and the last digit, which is a check digit.) The first 5 digits are the manufacturer's number, as assigned by the Uniform Code Council in Dayton, OH. The last 5 digits are the product number, as assigned by the manufacturer. The encoding for the 10 digits are given in the table. The encoding is not the standard binary, but rather a prescribed set of 7 bits. A "0" represents a white bar of unit length and a "1" represents a black bar of unit length. For example, the digit 3 is represented by "0111101", which means a white bar of unit width, followed by a black bar of width four, then a unit width white bar, and finally a unit width black bar.
| Digit | Manufacturer's Number | Product Number |
| 0 | 0001101 | 1110010 |
| 1 | 0011001 | 1100110 |
| 2 | 0010011 | 1101100 |
| 3 | 0111101 | 1000010 |
| 4 | 0100011 | 1011100 |
| 5 | 0110001 | 1001110 |
| 6 | 0101111 | 1010000 |
| 7 | 0111011 | 1000100 |
| 8 | 0110111 | 1001000 |
| 9 | 0001011 | 1110100 |
The manufacturer's number and product number are always separated by the string "01010". This ensures that unit width black and white bars are present to calibrate the relative widths to. Note that the digits for the manufacturer's number always contain an odd number of 1's, whereas the product number digits always have an even number of 1's. This tells the computer scanner whether the barcode was scanned left to right or right to left. (So the clerk at the grocery store doesn't have to worry about scanning the barcode upside-down.) The bars for distinct digits will not "run together," since the manufacturer's number digit all begin with a 0 and end with a 1, and vice-versa for the the product number digits. Note that the longest string of 1's or 0's will have width four. Of course, this always relative to the width of the shortest bar, the so-called unit width. So regardless of the size of our signal, we should be able to classify each bar as having integral width one, two, three, or four.
A clean barcode signal will be a step signal alternating between 0 and 1. Since we are trying to detect where the jumps occur, it is often helpful to look at the first derivative. A clean derivative signal will be a series of Dirac delta functions alternating between -1 and 1. The program upc2signal.m takes a 10 digit string and generates the barcode signal and shows the first derivative. The figure below is the result of typing "b=upc2signal('0123456789')".

Back to Main Page |
Next: Noise and Denoising |