If one color modules are much than other color or pattern like "finder pattern" exists,
decoder application can have many mistake.
To prevent above case,best mask pattern which is selected from among 8 pattern is covered
in QRcode.

2.5.1 Range of masking

Range of masking is code words which is excepted "finder pattern","timing pattern" etc.

2.5.2 Condition of masking

We have 8 mask pattern in QRcode.
Mask pattern indicator is 3 bit long binary representation.

mask pattern indicator

condition

000

(i+j) mod 2 = 0

001

i mod 2 = 0

010

j mod 3 = 0

011

(i+j) mod 3 = 0

100

(( i div 2)+(j div 3)) mod 2 = 0

101

(ij) mod 2 + (ij) mod 3 = 0

110

((ij) mod 2 +(ij) mod 3) mod 2 = 0

111

((ij)mod 3 + (i+j) mod 2) mod 2 = 0

"mod" means remainder calculation, "div" means integer divide

in mask pattern 000....
at (20,20) : (20+20) mod 2 = 0 and reverse bit
at (19,20) : (20+19) mod 2 = 1 and do not reverse bit

2.5.3 Select mask pattern

We estimate result of above mask pattern to select.
We select a mask pattern which has least down point to calculate in which below table.
In addition conditions are applied to whole symbol.

characteristics

condition

down point

concatenation of same color in a line or a column

count of modules=(5+i)

3+i

module block of same color

block size 2*2

3

1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column

40

ration of dark modules in whole

from 50±(5+k)% to 50±(5+(k+1))%

10*k

I think it is not very important to select mask pattern exactly.
In fact there is different between result of JIS X0510(1999) appendix 8 and JIS X0510(2004) appendix G in same data.
And below result may is not exactly good.