MaskPatternTester
in package
Receives a QRData object and runs the mask pattern tests on it.
ISO/IEC 18004:2000 Section 8.8.2 - Evaluation of masking results
Tags
Table of Contents
- $qrData : QRData
- The data interface that contains the data matrix to test
- __construct() : mixed
- Receives the QRData object
- getBestMaskPattern() : MaskPattern
- shoves a QRMatrix through the MaskPatternTester to find the lowest penalty mask pattern
- testPattern() : int
- Returns the penalty for the given mask pattern
- testLevel1() : int
- Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and give penalty to them. Example: 00000 or 11111.
- testLevel2() : int
- Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
- testLevel3() : int
- Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we find patterns like 000010111010000, we give penalty once.
- testLevel4() : float
- Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
Properties
$qrData
The data interface that contains the data matrix to test
private
QRData
$qrData
Methods
__construct()
Receives the QRData object
public
__construct(QRData $qrData) : mixed
Parameters
- $qrData : QRData
Tags
Return values
mixed —getBestMaskPattern()
shoves a QRMatrix through the MaskPatternTester to find the lowest penalty mask pattern
public
getBestMaskPattern() : MaskPattern
Tags
Return values
MaskPattern —testPattern()
Returns the penalty for the given mask pattern
public
testPattern(MaskPattern $pattern) : int
Parameters
- $pattern : MaskPattern
Tags
Return values
int —testLevel1()
Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and give penalty to them. Example: 00000 or 11111.
private
testLevel1(array<string|int, mixed> $m, int $size) : int
Parameters
- $m : array<string|int, mixed>
- $size : int
Return values
int —testLevel2()
Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
private
testLevel2(array<string|int, mixed> $m, int $size) : int
Parameters
- $m : array<string|int, mixed>
- $size : int
Return values
int —testLevel3()
Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we find patterns like 000010111010000, we give penalty once.
private
testLevel3(array<string|int, mixed> $m, int $size) : int
Parameters
- $m : array<string|int, mixed>
- $size : int
Return values
int —testLevel4()
Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
private
testLevel4(array<string|int, mixed> $m, int $size) : float
Parameters
- $m : array<string|int, mixed>
- $size : int