MaskUtil
in package
Mask utility.
Table of Contents
- N1 = 3
- N2 = 3
- N3 = 40
- N4 = 10
- applyMaskPenaltyRule1() : int
- Applies mask penalty rule 1 and returns the penalty.
- applyMaskPenaltyRule2() : int
- Applies mask penalty rule 2 and returns the penalty.
- applyMaskPenaltyRule3() : int
- Applies mask penalty rule 3 and returns the penalty.
- applyMaskPenaltyRule4() : int
- Applies mask penalty rule 4 and returns the penalty.
- getDataMaskBit() : bool
- Returns the mask bit for "getMaskPattern" at "x" and "y".
- __construct() : mixed
- applyMaskPenaltyRule1Internal() : int
- Helper function for applyMaskPenaltyRule1.
Constants
N1
public
mixed
N1
= 3
N2
public
mixed
N2
= 3
N3
public
mixed
N3
= 40
N4
public
mixed
N4
= 10
Methods
applyMaskPenaltyRule1()
Applies mask penalty rule 1 and returns the penalty.
public
static applyMaskPenaltyRule1(ByteMatrix $matrix) : int
Finds repetitive cells with the same color and gives penalty to them. Example: 00000 or 11111.
Parameters
- $matrix : ByteMatrix
Return values
int —applyMaskPenaltyRule2()
Applies mask penalty rule 2 and returns the penalty.
public
static applyMaskPenaltyRule2(ByteMatrix $matrix) : int
Finds 2x2 blocks with the same color and gives 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.
Parameters
- $matrix : ByteMatrix
Return values
int —applyMaskPenaltyRule3()
Applies mask penalty rule 3 and returns the penalty.
public
static applyMaskPenaltyRule3(ByteMatrix $matrix) : int
Finds consecutive cells of 00001011101 or 10111010000, and gives penalty to them. If we find patterns like 000010111010000, we give penalties twice (i.e. 40 * 2).
Parameters
- $matrix : ByteMatrix
Return values
int —applyMaskPenaltyRule4()
Applies mask penalty rule 4 and returns the penalty.
public
static applyMaskPenaltyRule4(ByteMatrix $matrix) : int
Calculates the ratio of dark cells and gives penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
Parameters
- $matrix : ByteMatrix
Return values
int —getDataMaskBit()
Returns the mask bit for "getMaskPattern" at "x" and "y".
public
static getDataMaskBit(int $maskPattern, int $x, int $y) : bool
See 8.8 of JISX0510:2004 for mask pattern conditions.
Parameters
- $maskPattern : int
- $x : int
- $y : int
Tags
Return values
bool —__construct()
private
__construct() : mixed
Return values
mixed —applyMaskPenaltyRule1Internal()
Helper function for applyMaskPenaltyRule1.
private
static applyMaskPenaltyRule1Internal(ByteMatrix $matrix, bool $isHorizontal) : int
We need this for doing this calculation in both vertical and horizontal orders respectively.
Parameters
- $matrix : ByteMatrix
- $isHorizontal : bool