Dev. Waves Blog

QR Code Visual Structure

QR Code Structure

The designer of QR Code has put in effective graphic patterns that makes QR code looks cool and works robustly. Its ultimate fullest description is in the ISO standard No. 18004:2006.

A couple of years ago, I have wrote an encoder in Cpp and Javascript, and posted notes in here. During the process, it is convenient to make a couple of illustrative diagrams for the QR Code’s visual structure.

Visual Structure PNG file

There are 40 different sizes of QR Code referred in the ISO standard as Version 1, Version 2 … Version 40. The smallest QR Code, Version 1, sizes as 21x21 small blocks. And the largest QR Code, Version 40, has 177x177 blocks. The above figure shows the structure of QR Codes of different versions.

As shown in the figure, a QR Code is composed of a number of regions that form different patterns of blocks. Each of these special regions are specially designed by the standard to serve a given purpose. They are finder pattern, timing pattern, alignment pattern, version information pattern, format information pattern, and finally the main encoding region.

  1. Finder pattern - consist of three identical regions at the three corners of the QR code, as illustrated in the figure in black color. Each one is called in the standard as a Position Detection Patterns, and are located at the upper left, upper right and lower left corners. Each Posotion Detection Pattern can be viewed as three superimposed concentric squares which are 7x7 dark, 5x5 light and 3x3 dark, respectively. A scanner identifies the three Position Detection Patterns comprising the finder pattern, then can unambiguously determine the location and orientation of the symbol in the field of view.

  2. Timing pattern - shown in Figure as black and white blocks, which forms 7-th row and 7-th column in a QR Code. It indicates the size of each block in the code.

  3. Alignment patterns - shown in Figure as red blocks. Each alignment pattern a specially formed 5x5 blocks shown in Figure. The number of the patterns is determined by the version number. Only Version 1 code does not have alignment pattern.

  4. Version information pattern - shown in Figure as green blocks. There are two 3x6 blocks of pattern, and they are identical. For each 18 blocks, the version number between 1 to 40. (18,6) BCH code is used on the 18 blocks. Small QR Codes of version 1 to 6 do not have version information pattern.

  5. Format information pattern - shown in Figure as blue blocks. There are 15 blue blocks on the top-left corner, and they together encodes the format information of the QR Code. There are also 15 blue blocks together at the other two corners, they together form an identical copy of the first 15 blue blocks. Using 15 blocks, error correction level (among L, M, Q, H) is encoded. Also encoded in is the choice among 7 different mask patterns. (15,5) BCH code is used on the 15 blocks.

  6. Encoding region - shown in previous Figure as grey area of blocks. In actual QR Code, each dark block represent a bit 1, and each white block represent a bit 0. The next Figure shows in color of the blocks in the encoding region. QR Code symbols are placed one by one in the encoding region. Each symbol is a byte, hence represented by 8 blocks. By default, a symbol is positioned in a two-block wide column. The 1st symbol is always placed at the bottom-right corner of the encoding region. Next symbol is placed on the top, and thus going up-wards, until reaching the upper boundary of the encoding region. Next symbol is then placed on the left, and further next symbols are placed down-wards. Thus, the placement direction is alternating.

The next figure, each same-color 8-block pattern represent a QR Code symbol. Notice that how each pattern will need to skip the blocks that is occupied for alignment patterns or Version information patterns.

QR Coding Blocks

End of Blog

#Post #Programing