Detecting bar and space width

The recognition is preceeded with automatic image quality enhancement that decreases the noiseness of lines and compensates the small slip of rows.

Apart from the binarity or non-binarity of the barcodes, decoding methods always start with determining the width of each bar and space and making a distribution method of them. For perfect barcodes these methods always contain only the number of width type non-zero values (e.g. a perfect binary barcode’s bar distribution method has only 2 different places (widths) with non-zero values). Unfortunately a scanned barcode is never perfect, so these distribution methods are much more complex.

In the following example let’s assume that a binary barcode is available with 7 thin (width = 4) and 5 narrow bars (or spaces) (width = 10). The charts below show the distribution method of a perfect and a non perfect (e.g. scanned) barcode’s bars (or spaces).

For a perfect non-binary barcode the number of non-zero places is 3 (or sometimes more), and there are different ways to detect the logical widths (thin, narrow, etc.) of  the bars (or spaces).